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
Post a Comment