c# - MVC Unable to display Linq query result to view -
c# - MVC Unable to display Linq query result to view -
i'm trying display linq results view have not been able to. error "the model item passed dictionary of type 'system.data.entity.infrastructure.dbquery1[<>f__anonymoustype22[system.double,system.string]]', dictionary requires model item of type 'system.collections.generic.ienumerable"
i created view manually , right clicking controller , adding view i'm kind of stuck here.
public actionresult leftjoin() { var q = b in db.orderhistories bring together c in db.buyercomms on b.itemid equals c.itemid sr x in sr.defaultifempty() select new { item = b.itemid, buyer = x.buyer }; homecoming view (q.tolist()); } and view:
@model ienumerable<myapp.models.orderhistory> i used linqpad test linq , i'm getting right results.
your query returning anonymous type indicated by:
select new { item = b.itemid, buyer = x.buyer }; you need instead select type of orderhistory. didn't provide class, i'm going guess it's like:
select new orderhistory { item = b.itemid, buyer = x.buyer }; c# asp.net-mvc linq asp.net-mvc-5
Comments
Post a Comment