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 14:20:25
 
 
À
09/07/2011 13:28:29
John Baird
Coatesville, Pennsylvanie, États-Unis
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:
01517821
Vues:
40
>>>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()?

The table rows already implement IEnumerable. I guess you just have to force the enumeration. Something like? :
DataSet1.TableA.Select<DataSet1.TableARow, bool>(x => { DataSet2.TableA.ImportRow(x); return true; }).Count();
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform