Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is it possible to create a datatable from the LINQ?
Message
De
21/08/2013 02:16:39
 
 
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:
01580868
Vues:
29
>>>But I found (actually, David replied in my e-mail) that I can use properties of this anonymous type.
>>>So, looks like I can simply use code like this
>>>
>>>
>>>foreach (var row in resultingQuery)
>>>                     {
>>>                        DataRow newRow = dtReturn.NewRow();
>>>
>>>                        newRow["resource1"] = row.resource1;
>>>                        newRow["fname"] = row.fname;
>>>
>>>                        dtReturn.Rows.Add(newRow);
>>>                     }
>>>
>>>
>>>Wondering if this is easier than David's class or not.
>>
>>That is (according to old ADO.Net book I read) the slowest way to access and you do that in a tight loop across potentially oodles of rows.
>>Faster to get column index in advance or AFAIR fastest back then to query the column in advance (outside loop) and use that inside the loop.
>
>David also suggested that accessing column by index will be faster. I'll see if I can change it.

AFAIR the back then getting the column datatype was even faster integer index, but that might have changed through dotnet versions.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform