How to return specific list result from linq to entities -
hi experts currenly write code:
public ilist<tresult> getcustomquery<tresult>(int orderid, func<order, tresult> selector) { using(repositorydatacontext = new northwindentities()) { ilist<tresult> res = (from od in repositorydatacontext.order_details join o in repositorydatacontext.orders on od.orderid equals o.orderid join p in repositorydatacontext.products on od.productid equals p.productid join c in repositorydatacontext.customers on o.customerid equals c.customerid o.orderid > orderid select new { o.orderid, od.unitprice, od.quantity, p.productname, c.companyname }).select<order, tresult>(selector).tolist(); } }
i want return result of linq entities in specific format(tresult). writing code using lambda expression hard because of joins. line has exception :select < order, tresult > (selector) how can fix that? thanks
instead of creating anonymous type, create poco or in case order
select new order() { orderproperty1 = o.orderid, orderproperty2 = od.unitprice, orderproperty3 = od.quantity, orderproperty4 = p.productname, orderproperty5 = c.companyname }).select<order, tresult>(selector).tolist();
Comments
Post a Comment