c# - Convert sql query with arithmetic operators to LINQ -


i have following sql table

create table purchasingshipments (     id int identity(1,1) not null,     shipmentid 'psid' + right('00000000' + cast(id varchar(8)), 8) persisted primary key,     title varchar(300),     noofpieces integer,     priceperpiece money,     actualcostperpiece money,     micelleneous money,     year integer,     month integer,     date integer,     transportcost money,     suppliercommission money,    ) 

and have following sql query retrieve data above table:

select      year(date) 'year',     sum(noofpieces * priceperpiece + micelleneous + transportcost + suppliercommission) 'cost' purchasingshipments group year(date) 

i'm using visual studio 2013 entityframework 6. need convert above query linq. how can that?

it like:

var qry = ps in purchasingshipmentsentity     group ps ps.year grp     select new     {          year = grp.key,          cost = grp.sum(x=> x.noofpieces * x.priceperpiece + x.micelleneous + x.transportcost + x.suppliercommission)     }; 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -