Linq to Enity complex query
I have entity which开发者_开发技巧 contains Id, Price
columns
I want to build linq to entiy
query which would count
the number of rows, summarize the Price
and than subtract count
from Price
and multiplied the result by one hounded
.
(Count(*) - SUM(Price))*100
Is it possible to create such single query with entity framework 4.0?
this should work
var ris = (from p in dc.Products group p by p into a select (a.Count() - a.Sum(z => z.UnitPrice)) * 100).First();
or
var ris= dc.ExecuteStoreQuery<double>("select (Count(*) - SUM(Price))*100 from mytable");
精彩评论