Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Transformations on returned data set
Message
De
09/05/2013 17:22:42
 
 
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
Divers
Thread ID:
01573095
Message ID:
01573319
Vues:
39
This message has been marked as a message which has helped to the initial question of the thread.
>>So is there a reason you didn't create a new table an manually loop through the rows? You are trying to force LINQ to do something it wasn't designed to do (create a new DataTable with a different structure). If you need the results as a DataTable, it needs to have a structure defined so that DataRows can be created for it. If you don't want to do that, you could write a method that would convert an IEnumberable< object> to a DataTable. Or you could create a class to hold the results of your query and use that instead of a DataTable to pass the results to the other function.
>
>I thought I can use LINQ to do this transformation in memory without a need to loop through the rows. But looks like I would need to do it manually as suggested by Bill originally.
>
>Unless I will try to incorporate most of the code from our conversion methods here.
>
>The only reason I need a datatable is because our method to convert to our XML string accepts datatable. Since it loops through every row, it means I would need double looping. I'd rather try to figure out if I can somehow create something similar to use and do that loop directly myself.

You do realize that the LINQ query would also be looping through the rows, right? The only thing you could do without looping would be to add DataColumns with expressions (http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx), but that wouldn't handle the proper or replicate functions without some very messy code.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform