I’ve been assigned a new project at work which uses NHibernate. A query that I can easily write in sql has me totally stumped on how to do it in linq, which is how I’ve been told to do it.
So, here’s the query:
select ts.BatchID, COUNT(distinct ts.UniqID) SurveyCount
from TeleformStaging.TeleformStaging ts
where ts.IsRescan = 0
and not exists (select bfr.BatchID
from TeleformStaging.BatchesForRescan bfr
where bfr.BatchTrack = ts.BatchID)
group by ts.BatchID
order by ts.BatchID
I believe I could get the ‘group by’ portion, but no idea on the subquery.
Thanks for any advice…
Maybe something like this:
where db is the linq data context
Edit
You could also do it with
.Any(). Like this:Edit 1
Useful links: