vb.net - select as field in Linq -
i new linq , trying convert following sql query linq;
select c.clientid , c.clientname , isnull((select 1 clientcontactaccess cca cca.clientid = c.clientid , clientcontactid = 2141 ), 0) 'clientaccess' clients c c.groupid = 1
i have tried far don't know include clause;
dim query = (from c in db.client select new _ {key .clientid = c.clientid, _ key .clientname = c.clientname, _ key .clientaccess = (from cca in db.clientcontactaccess cca.clientid = c.clientid , cca.clientcontactid = _contactid)})
updated:
i have managed come far clientaccess field returns no value. need return either 1 or 0.
dim query = (from c in db.client c.groupid = 1 select new _ {key .clientid = c.clientid, _ key .clientname = c.clientname, _ key .clientaccess = (from cca in db.clientcontactaccess cca.clientid = c.clientid , cca.clientcontactid = _contactid)})
i tried convert sql query i'm not sure work , think converting query result in c# , need little bit change need.
var result=from c in clients select new {c.clientid,c.clientname, cca.where(x=>x.clientid=c.clientid && x.clientcontactid=2141).any()} c.groupid==1;
Comments
Post a Comment