Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is it possible to create a datatable from the LINQ?
Message
De
19/08/2013 03:15:02
Thomas Ganss (En ligne)
Main Trend
Frankfurt, Allemagne
 
 
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:
01580740
Vues:
25
>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform