I'm writing Select-statements with joins in C# with Vs 2015. Now i got a special join with multiple parameters which come - under circumstances - from different tables which complicates all a little bit.
How can i write the following statement correctly?
TestPointToInputMask tpm2 =
(from m in ent.InputMask
join tm in ent.TestPointToInputMask on m.inputMaskId equals tm.inputMaskId
join tp in ent.TestPoint on tm.testPointId equals tp.testPointId
join tc in ent.TestPointToChapter on tp.testPointId equals tc.testPointId
join c in ent.Chapter on tc.chapterId equals c.chapterId
join dc in ent.Description on c.textKey equals dc.textKey and dc.languageId == 1
join dp in ent.Description on tp.textKey equals dp.textKey and dp.languageId == 1 and dp.text.StartsWith(testPointText)
where m.inputMaskName.ToUpper() == inputMaskName.ToUpper()
&& tp.testPointNumber.ToUpper() == testPointNumber.ToUpper()
&& dc.text.ToUpper() == chapterText.ToUpper()
&& c.testTypeId == testTypeId
select tm).FirstOrDefault();
As You can see i have there two joins in which i use "and" which don't work. I tried another version but it's very slow.
TestPointToInputMask tpm2 =
(from m in ent.InputMask
join tm in ent.TestPointToInputMask on m.inputMaskId equals tm.inputMaskId
join tp in ent.TestPoint on tm.testPointId equals tp.testPointId
join tc in ent.TestPointToChapter on tp.testPointId equals tc.testPointId
join c in ent.Chapter on tc.chapterId equals c.chapterId
join dc in ent.Description on c.textKey equals dc.textKey
join dp in ent.Description on tp.textKey equals dp.textKey
where m.inputMaskName.ToUpper() == inputMaskName.ToUpper()
&& tp.testPointNumber.ToUpper() == testPointNumber.ToUpper()
&& dc.text.ToUpper() == chapterText.ToUpper()
&& c.testTypeId == testTypeId
&& dc.languageId == 1
&& dp.languageId == 1 && dp.text.StartsWith(testPointText)
select tm).FirstOrDefault();
Any help would be appreciated.