how can I filter a list that is being returned by a stored procedure?

I have a stored procedure that returns a list of records. If I execute the stored procedure in Linqpad and dump the output, the output is displayed correctly on screen.

var dbRecords = RAMFindMissingItemsByInspectionId (38).Dump();

As soon as i insert a Where clause on the records, Linqpad throws a compile time error

var dbRecords = RAMFindMissingItemsByInspectionId (38).Where(y => y.InspectionCategoryId == 1);

CS1061 'ReturnDataSet' does not contain a definition for 'Where' and no accessible extension method 'Where' accepting a first argument of type 'ReturnDataSet' could be found (press F4 to add an assembly reference or import a namespace)

How to apply a filter on the records being returned by the stored procedure?


  • Don't know if there is a better way, but I have used AsDynamic()

    eg on the Northwind sample

    SalesbyYear(new DateTime(1900,1,1), DateTime.Now)
       .Where(a=>a.Subtotal > 10000)

    You could also do

    SalesbyYear(new DateTime(1900, 1, 1), DateTime.Now)
        .Where(a => (decimal) a["Subtotal"] > 10000)
  • Excellent, that works for me. Thank you for taking the time to respond to my post.

    var dbRecords = RAMFindMissingItemsByInspectionId (38);
    dbRecords.AsDynamic().Where(a => a.InspectionId ==0).Dump();
Sign In or Register to comment.