linq with select distinct and count for the C# application -
i have 2 sql query, have tested both queries working. need convert linq query dropdown list(mvc c#). there way linq query should display date without time? eg date 2015-09-30
select distinct deldate location dstatus = 'true' , fstate = 'true'
output
2015-09-30 14:06:37.000 2015-09-30 14:14:09.547
my second query, need convert linq list only
select count(distinct couname) statuscount location dlstatus = 'true' , fstate = 'true' , couname = 'alan'
as per sql
in question, equivalent linq
be
select distinct deldate location dstatus = 'true' , fstate = 'true'
var deldates = location .where(l => l.dstatus == "true" && l.fstate == "true") .select(f => f.deldate) .distinct();
select count(distinct couname) statuscount location dlstatus = 'true' , fstate = 'true' , couname = 'alan'
var statuscount = location .where(l => l.dstatus == "true" && l.fstate == "true" && l.couname == "alan") .select(f => f.couname) .distinct() .count();
Comments
Post a Comment