I'm trying to select the MatchingObjects that doesn't exist in the Unlock table , I have this SQL query as following:

```
select a.* from MatchingObjects a 
    left join Unlocks b
        on a.ObjectCategoryId = b.ObjectCategoryId
    left join Members c
        on b.StudentId = c.Id
            and b.StudentId = @studentId
where  b.ObjectCategoryId is null
    and c.id is null
order by a.ObjectCategoryId

```

And a LINQ query

```
var query = (from d in db.ObjectCategories
                     join a in db.MatchingObjects on d.Id equals a.ObjectCategoryId into grp3
                     join b in db.Unlocks
                         on d.Id equals b.ObjectCategoryId into grp1
                     from m in grp1.DefaultIfEmpty()
                     join c in db.Members
                         on m.StudentId equals c.Id into grp2
                     from n in grp2.DefaultIfEmpty()
                     where m.ObjectCategoryId == null
                     && n.Id == null
                     orderby d.Id).AsEnumerable()
                     ;

```

However, the LINQ query is not showing the same result as that I want like in the SQL query. Could you guys tell me what I should change in my LINQ Query?

This is the model:
[![enter image description here](https://i.stack.imgur.com/I1exa.png)](https://i.stack.imgur.com/I1exa.png)