c# - Linq query expression -


i writing join query produces anonymous result set. problem don't know data type should returned function service , tried return object type don't know how access elements of result in source code...

here code:

 public static ienumerable<object> getproductsalesinfobyid(int id)  {      var query = product in database.products          join sales in database.salesorderdetails              on product.productid equals sales.productid          select new  {name = product.name,orderid = sales.salesorderid,totalprice = (sales.unitpricediscount)*sales.orderqty*sales.unitprice};       ienumerable<object> result = query.tolist();      return result;  }  

you should create dto class contains properties in anonymous object , return ienumerable<t> of it. not solution use dynamic wouldn't use that.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -