Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Linq Blues
Message
 
 
À
14/01/2015 08:10:30
John Baird
Coatesville, Pennsylvanie, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Versions des environnements
Environment:
C# 4.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01613589
Message ID:
01613596
Vues:
42
>>>Succeeded in getting this passed the editor. Note that customers is a DataTable.
>>>
>>>  IEnumerable<DataRow[]> r1 = (IEnumerable<DataRow[]>) customers.AsEnumerable().Where(r => (r["ID"] == ID));
>>>
>>>
>>>now how do I get the first row cast as a DataRow?
>>
>>var Rows = customers.AsEnumerable().Where(r => (r["ID"] == ID));
>>
>>DataRow r1 = new DataRow();
>>int i = 0
>>foreach (var Row in Rows)
>>
>>{
>>  if (i=0)
>>    {
>>     r1 = Row;
>>     break;
>>   }
>>}
>>
>>from the top of my head - not tested.
>
>
>What?
>
>var q = customers.AsEnumerable().FirstOrDefault(r => r.Field<int>("id") == ID);
>
>
>In this case, q is TRow which is DataRow by default. (| should be a greater than ). Why would you suggest such a klunky work-around?

I was thinking the result is some sort of Enumerable of DataRows, not a single DataRow. Most likely you're right and we can use the direct approach.
If it's not broken, fix it until it is.


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

Click here to load this message in the networking platform