tags:

views:

36

answers:

1

Please help I am getting the following error when I am binding the drop down list in the form Unable to cast object of type 'System.Data.Objects.ObjectQuery1[<>f__AnonymousType02[System.String,System.Int32]]' to type 'System.Collections.Generic.List`1

I have written the query in Linq language

return (IList )(from p in db.tbl_PRODUCT_CATEGORY select new { catname = p.category_name, catid = p.category_id, });

I don't know whether it is correct

Please give me the correct format of the query

A: 

I think your query should look more like this:

return (IList)(from p in db.tbl_PRODUCT_CATEGORY select new { catname = p.category_name, catid = p.category_id, }).ToList();
cottsak
Thanks very much
Ritz
(IList) is not required
Esben Skov Pedersen
@EsbenP: +1 agreed
cottsak