templateSetId
テンプレートセットテーブルに存在するかどうかを確認しているため、linqでテーブルを結合するのに問題があります
クエリ:
select
vc.RowID, Choice_Text, VCE.[Goto]
from
ropes.Validation_Choices vc
left outer join
ropes.Validation_Condition_Expression VCE
on VCE.ChoiceID = vc.RowID and TemplateSetID in
(select RowID
from ropes.Validation_Templates_Set
where TemplateID = 66)
where
vc.QuestionID = 81
このクエリは 3 行を返します。
templatesetid のフィルターを移動すると、「演算子 '&&' は 'int 型のオペランドに適用できませんか?' というエラーが表示されます。そして「bool」」私ができる最善のことはこれです
from tc in _context.ValidationChoice
join vce in _context.ValidationConditionExpression
on tc.ChoiceId equals (int)vce.ChoiceID into lfc
from lf in lfc.DefaultIfEmpty()
where tc.QuestionID == questionId &&
(from ts in _context.ValidationTemplateSet where ts.TemplateID == templateId select ts.TemplateSetId).Contains((int)lf.TemplateSetID)
select new TemplateChoiceDTO
{
ChoiceId = tc.ChoiceId,
ChoiceText = tc.ChoiceText,
NextQuestionId = lf.Goto
};
これは次と同等です:
select vc.RowID,Choice_Text,VCE.[Goto] from ropes.Validation_Choices vc
left outer join ropes.Validation_Condition_Expression VCE on
VCE.ChoiceID = vc.RowID
where vc.QuestionID = 81
and TemplateSetID in (select RowID from ropes.Validation_Templates_Set where TemplateID = 66)
templatesetid のフィルターが外側に移動されたため、このクエリは 1 行を返します。