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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -