score:0

I rewrote the query to be exactly like the sql query, i believe that this is the way:

var firstQuery = (from u in this.ViewSelectorControl.LDReviewContext.GetTable<UserViewDoc>()
                  where IDs.Contains(u.UVID)
                  select u.DocID).Distinct();

var innerQuery = (from u in this.ViewSelectorControl.LDReviewContext.GetTable<UserViewDoc>()
                      join uvh in this.ViewSelectorControl.LDReviewContext.GetTable<UserViewHeader>() on uvh.UVID equals u.UVID
                      where IDs.Contains(u.UIVD) == false
                      && uvh.IsLock
                      select u.DocID).Distinct();

var resultQuery = from f in firstQuery
                  join i in innerQuery on i equals f into lout
                  from i in lout.DefaultIfEmpty()
                  where i == null
                  select f;

Related Articles