Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select from one strongly typed dataset to another
Message
From
11/07/2011 12:25:18
 
 
To
11/07/2011 11:47:21
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01517609
Message ID:
01517878
Views:
42
>>You could try something in Linq. e.g:
DataSet1.TableA.Where(x=>x.Name=="Fred").ToList().ForEach(x => DataSet2.TableA.ImportRow(x));

>So, this got me thinking. I had written a blog post a few months ago about benchmarking DataTable Selects vs LINQ Selects. If I recall, LINQ wasn't really performant for some queries when it was first introduced and I wanted to re-visit that. It turns out that LINQ was much faster (http://geek-goddess-bonnie.blogspot.com/2011/04/linq-with-datasets.html). In that post, I said I'd write more later on other DataSet vs LINQ benchmark comparisons, but never got around to it.
>
>So, I thought I'd try and benchmark the DataSet CopyToTable from my earlier suggestion to Bill, vs the above LINQ statement that Viv posted that does the same thing. LINQ was more than 1.5 times faster (against a Typed DataSet ... haven't yet benchmarked against a regular DataSet). As in the example in my blog post, I was using a DataSet containing 270,000 rows and copying 30,000 rows. I haven't written a new blog post yet, but I will in the next couple of days.
>
>~~Bonnie
Hi, Interesting (would be more so if I actually used DataSets any more :-} )
Actually I'm surprised that Linq was faster. I see that .CopyToDataTable() creates the return table by reference to the row schema but that shouldn't be much of an overhead. But, disconcertingly, I notice that, for a typed dataset, types are not preserved. Out of curiosity I wonder how something like this might perform:
var q = from  sr in ds1.TableA where sr.Name == "Fred" select sr;
DataTable t = q.CopyToDataTable();
Previous
Reply
Map
View

Click here to load this message in the networking platform