I have a query that works perfectly in SQL, but I\'m having the damnedest time converting it to linq. The table (Table1 below) holds status changes for multiple record types
I think a direct translation of your SQL would look like this:
var q = from ds in table1
where ds.SubmissionTypeId == 1 || ds.SubmissionTypeId == 2
from di in table2
from dr in table2
where (ds.SubmissionTypeId == 2 && ds.SubmissionId == di.Id)
|| (ds.SubmissionTypeId == 1 && ds.SubmissionId == dr.Id)
select ds;
However, it seems unlikely that this is what you want. If I may speculate about what your intended logic is, I think you want something more like this:
var q = from ds in table1
where (ds.SubmissionTypeId == 2 && table2.Any(di => ds.SubmissionId == di.Id))
|| (ds.SubmissionTypeId == 1 && table3.Any(dr => ds.SubmissionId == dr.Id))
select ds;