Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select from one strongly typed dataset to another
Message
From
09/07/2011 14:20:25
 
 
To
09/07/2011 13:28:29
John Baird
Coatesville, Pennsylvania, United States
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01517609
Message ID:
01517821
Views:
39
>>>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();
Previous
Reply
Map
View

Click here to load this message in the networking platform