You can try to do a left join and filter the null entries. Without test data, I canβt say for sure if it will work out of the box, but several times I used the following code to perform this filtering:
db.Users.Join(db.Abjusters, outer => outer.id, inner => inner.userID, new { User = outer, Adjuster = inner }) .GroupJoin(DBConcurrencyException.AdminAdjusterStatus, outer => outer.Adjuster.id, inner => inner.adjusterID, new { User = outer.User, Adjuster = outer.Adjuster, Admins = inner }) .SelectMany(grp => grp.Admins.DefaultIfEmpty(), (grp, admin) => new { User = grp.User, Adjuster = grp.Adjuster, Admin = admin }) .Where(item => item.User.userType == "adjuster" && item.Admin == null) .Select(item => new AdjusterProfileStatusItem { user = item.User, adjuster = item.Adjuster });
The GroupJoin / SelectMany combination performs the union on the left, and then you can filter where the object is null, which should create the same as NOT IN.
source share