views:

36

answers:

1

Hi there,

I have to join results from 2 sprocs in LINQ but got the error message: 'System.Data.DataSet' does not contain a definition for 'Where' and no extension method 'Where' accepting a first argument of type 'System.Data.DataSet' could be found (press F4 to add a using directive or assembly reference)

However after added the DataSetExtensions the error still appears.

Code:

var c = GetAllGameCategories (123);
var d = GetGameCategories(22458);

Var e = c.Where(....);  // Error on this line!

Any help appreciated.

A: 

A DataSet is a collection of DataTable objects.
It does not directly contain any data.

You need to call .Where() on the DataTable.
EDIT: If it isn't a typed DataTable, you'll need to call .AsEnumerable() first.

SLaks
Why was this downvoted?
SLaks
because it is incorrect
Simon Fox
@Simon: ​​​​How?
SLaks
Thanks SLaks, appreciated for your help.
codemonkie
The result is from SPROC query, sorry I didn't explicitly state what exactly the type it is, but from LINQPad I got the impression that its treated as DataSet by default. I was using LINQPad to test out my lambdas but at the end I use the .ToArray() to both c and d back in the code as a work around.
codemonkie
And do the JOIN as in....
codemonkie
foreach (var item in c) { foreach (var item2 in d) { if (item.ID == item2.ID) { return item.ShortDescription.ToString(); } } } // Return a null string if match failed. return null;
codemonkie