Help with LINQ to SQL group by query -
the linq group syntax confusing me. in tsql can select multiple columns , group 1 of them. linq it's making me group of columns want work with.
how can convert tsql linq?
select max(item.itemid) expr1, max(item.title) expr2, sum(orderdetail.quantity) qty, max([order].datecreated) expr3 payment inner join [order] on payment.id = [order].orderid inner join orderdetail on [order].orderid = orderdetail.orderid inner join item on orderdetail.itemid = item.itemid ([order].datecreated >= '4 / 15 / 2011 12:00:00 am') , ([order].datecreated <= '4/15/2011 11:59:00 pm') group item.itemid order expr2 var q = p in db.payments join o in db.orders on p.id equals o.paymentid join od in db.orderdetails on o.orderid equals od.orderid join in db.items on od.itemid equals i.itemid j1 j2 in j1 o.datecreated >= new datetime(2011, 4, 15) group j2 j2.itemid g select new { g.key };
var query = p in db.payments join o in db.orders on p.id equals o.orderid join od in db.orderdetails on o.orderid equals od.orderid join in db.items on od.itemid equals i.itemid o.orderdate.date == new datetime(2011, 4, 15) group new { i.itemid, i.title, od.quantity, o.datecreated } i.itemid g let expr1 = g.max(x => x.itemid) let expr2 = g.max(x => x.title) let qty = g.sum(x => x.quantity) let expr3 = g.max(x => x.datecreated) orderby expr2 select new { expr1, expr2, qty, expr3 };
Comments
Post a Comment