i'm struggling write linq version of query uses sql grouping. following show's example of sql i'm trying convert..
select count(*) ( select distinct t2.tableoneid, sum(t2.statusid) tabletwo t2 inner join tableone t1 on t1.tableoneid = t2.tableoneid t1.date between '2013-10-07 00:00:00.000' , '2013-11-07 00:00:00.000' , t1.active = 1 group t2.tableoneid having count(t2.tableoneid) = 2 , sum(t2.statusid) = 3 ) groups
here attempt made, returns 0 results.
var tomorrow = date.adddays(1); var total = (from t2 in _db.tabletwo join t1 in _db.tableone on t2.tableoneid equals t1.tableoneid t1.date >= date && t1.date < tomorrow && t1.active == 1 group t2 t2.tableoneid grouped grouped.count() == 2 && grouped.sum(x => x.statusid) == 3 select grouped.distinct()).count();
Comments
Post a Comment