Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<AnonymousType#1>' to 'System.Linq.IQueryable' -
i want define function containing linq query bellow:
public iqueryable getbasket(guid userid) { dabbaghandatacontext db = new dabbaghandatacontext(); int rowno = 0; var query = (from c in db.carts bring together co in db.cartorders on c.id equals co.cart_id bring together p in db.products on co.product_id equals p.id c.userid == userid && c.issued == false select new { co.quantity, co.totalprice, p.code, p.price, p.thumbnail }).asenumerable().select(r => new { rownumber = ++rowno, quantity = r.quantity, totalprice = r.totalprice, code = r.code, cost = r.price, thumbnail = r.thumbnail }); homecoming query; }
i error
cannot implicitly convert type 'system.collections.generic.ienumerable' 'system.linq.iqueryable'.
on return query
line.
what problem? how can solve problem? please help.
your problem phone call asenumerable
- converts iqueryable
ienumerable
; , therefore, cannot homecoming iqueryable
.
correct me if wrong, sec select seems add together row number result. might want initial select, , skip phone call asenumerable()
.
possible solutions: rewrite query not utilize asenumerable
(if want iqueryable
returned), or alter homecoming type ienumerable
, if improve fit problem.
linq
No comments:
Post a Comment