Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select from one strongly typed dataset to another
Message
De
09/07/2011 13:28:29
John Baird
Coatesville, Pennsylvanie, États-Unis
 
 
À
09/07/2011 13:17:44
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 3.0
Divers
Thread ID:
01517609
Message ID:
01517815
Vues:
44
>>Thanks for the tip Bonnie.
>>
>>I tried the code befow but get a message that " vfppriceds.icpric cannot be assigned to.. etc"
>>
>>So I copped out and looped thru the rows of source table of ds1 and imported the selected rows into the target table of ds2.
>>Not very pretty, tho.
>>There must be a better way.
>
>> vfppriceds.icpric = (MeycoPro60DataDataSet.icpricDataTable)ordVFPPro60.vfpds.icpric.Select("item = " + item).CopyToDataTable();
>
>You could try something in Linq. e.g:
DataSet1.TableA.Where(x=>x.Name=="Fred").ToList().ForEach(x => DataSet2.TableA.ImportRow(x));
Probably possible to improve by using a select with Action(T) instead of needing to create a list but haven't got C# in front of me and don't trust myself to write that unchecked :-{

Can't you use .AsEnumerable() too to avoid the use of .ToList()?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform