Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is it possible to create a datatable from the LINQ?
Message
De
18/08/2013 14:35:01
John Baird
Coatesville, Pennsylvanie, États-Unis
 
 
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:
01580729
Vues:
41
>>>I am going to try now this solution http://archive.msdn.microsoft.com/LinqEntityDataReader by MS employee David Browne.
>>
>>Why do you flit from one thing you can't understand to another, to another..... Just loop through the Linq collection and build a datatable. No problem at all...
>
>I wanted to try this idea, but I don't know how to access the fields in the anonymous type.
>
>In other words, can you show me what can I do here?
>
>
> foreach (var row in resultingQuery)
>
>
>
>I can not convert row into DataRow, therefore I don't see a way to access each individual column of that resulting query. David's class solves this problem, but if I can create a simpler code, I'd love to.


I haven't tried with anonymous types, I mostly use concrete classes to select into. But through reflection you can enumerate the fields & properties in the object and then create the Data table based on these..... If the extension method works for you and creates what you need, this will probably be the simplest solution going forward...
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform