I have to generate a List of IDs (int) from a table with Linq-Query for specific Conditions (count of specific column = 0).
In SQL having a Statement like:
select id
from person
where (select count(*) from mitgliedschaft
where mitgliedschaft.person_id = person.id
AND (austritt IS NULL OR austritt > getDate())) = 0
Trying to do this with Linq:
List<int> personIDsOhneAktuelleMitgliedschaft = db.mitgliedschaft
.Where(x => x.deletedFlag == 0 && (x.austritt == null || x.austritt > DateTime.Now))
.Select(x => x.person_id.Value)
.ToList();
I dont know how to set it up, to check the count = 0 in the where-part!
Can someone help me please?