Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is it possible to create a datatable from the LINQ?
Message
 
 
À
16/08/2013 08:53:06
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01580581
Message ID:
01580631
Vues:
33
>>>From the above link:
>>>Although this is useful, it does not allow tables to be created from a sequence of scalar types, from queries that project anonymous types, or from queries that perform table joins
>>
>>Right.
>>
>>I tried implementing the MS documented solution of creating custom CopyToTable method, but this seems to lead to other problems. First warning message I posted. I found I need to set ComVisible(false) to fix that message.
>>
>>But now I am getting the other warning
>>
>>Warning 4 "C:\Dev\Siriusware.Middleware\Siriusware.Middleware\bin\Debug\Siriusware.Middleware.dll" does not contain any types that can be registered for COM Interop. Siriusware.Middleware
>>
>>So, I am not sure if I need to pursue that method or try to figure something else. My end result is to produce a string and the only reason I need a datatable is because the method that generates that string accepts datatable.
>
>Since your original query uses a join (and CopyToDataTable() doesn't support it) there doesn't seem much point in pursuing that approach :-}
>
>Seems to me your options are:
>(a) Convert the query results into the required DataTable using code or
>(b) Writing a version of the method that accepts the IEnumerable.
>
>If the code in the method is complex then maybe write an overload that accepts the IEnumerable, converts it to a DataTable and passes that to the existing method?

The code in the method is not very complex, but it has several implementations depending on Return Type.

I am going to try now this solution http://archive.msdn.microsoft.com/LinqEntityDataReader by MS employee David Browne.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform