c# - Nested SQL to LINQ -
i have 3 tables as
- documents(documentid, documentname)
- subjects(subjectid, subjectname)
- documentsubjects (documentid,subjectid)
i want documents form documents table subjectid id provided input sql query
select * documents documentid in ( select documentid documentsubjects subjectid= 2 );
i want query in linq , please can me , in advance. :)
context.documents.where(d=>d.subjects.any(s=>s.subjectid == 2))
or
context.subjects.where(s=>s.subjectid == 2).selectmany(s=>s.documents).distinct()
Comments
Post a Comment