LINQ - LEFT OUTER JOIN with parameter -
can please me sql can't head around. in t-sql looks this:
select v.errandtype , count(s.ivrtasktype) v_errands v left outer join statisticsrequest s on s.ivrtasktype = v.ivrtasktype , s.registrationdate >= '2014-03-24 00:00:00.000' , s.registrationdate <= '2014-03-24 23:59:59.000' , s.countryid = 0 group v.errandtype
but in linq...that language is...so freaking weird, dont it.
greatly appreciate on this.
defaultifempty
left joindatetime
variables outside linq query- anonymous type grouping, can count other tables column
datetime start = new datetime(2014,03,24); datetime end = new datetime(2014,03,25); var query = v in context.v_errands s in context.statisticsrequest.where(x => x.ivrtasktype == v.ivrtasktype) .where(x => x.registrationdate >= start && x.registrationdate < end) .where(x => x.countryid == 0) .defaultifempty() group new { v, s} v.errandtype g select new { errandtype = g.key, count = g.select(x => x.s.ivrtasktype).count(), };
Comments
Post a Comment