Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is it possible to create a datatable from the LINQ?
Message
From
18/08/2013 14:35:01
John Baird
Coatesville, Pennsylvania, United States
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01580581
Message ID:
01580729
Views:
42
>>>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...
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform