tags:

views:

133

answers:

3

Hi, I have a simple select from a typed dataset:

var productlist = from prds in dsProducts.sk_products.AsEnumerable()
                          join prdcat in dsProducts.sk_productscategories.AsEnumerable() on prds.Field<int>("productid") equals prdcat.Field<int>("productid") where prdcat.Field<int>("categoryid") == categoryid
                          select prds;

Where productlist is set of records from the Dataset's sk_products datatable. I'd like to write a function to filter the records more, with a distinct on one of it's columns:

 public List<string, string> GetDistinctManufacturerList(? productlist, int manufacturerid)
    {
       manufacturers = from prdz in productlist where prdz.Field<int>("manufacturerid") == manufacturerid select prdz; [...]
    }

With what type of object should I refer to the variable productlist?

+2  A: 

Its an IEnumberable<selected data type> - the selected data type could be an anonymous type, or in this case, will be your dataset type class.

ck
IEnumerable<DataRow> was the answer, thank you!
balint
+1  A: 

I would guess something like IEnumerable<Product>. And as ck says, Product is the name of your LINQ data class.

Ronald Wildenberg
A: 

In your first example... mouse-over the word "var" in Visual studio, and it will display the "Type".

If it's something like 'anonymouse{blahblah}'... then you'll likely have to create a class that you want to convert it to so that you can use it as a function parameter.

Timothy Khouri