c# - Nested SQL to LINQ -


i have 3 tables as

  1. documents(documentid, documentname)
  2. subjects(subjectid, subjectname)
  3. 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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -