Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8489833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:56:16+00:00 2026-06-10T21:56:16+00:00

i have 4 table in SQL: DocumentType , ClearanceDocument , Request , RequestDocument .

  • 0

i have 4 table in SQL: DocumentType,ClearanceDocument,Request, RequestDocument.
i want when page load and user select one request, show all Document Based on clearanceType in RequestTable and check in RequestDocument and when exist set is_exist=true

I have written this query with SqlServer Query Editor for get result this Scenario but i can’t convert this Query to Linq

    select *,
    is_Orginal=
    (select is_orginal from CLEARANCE_REQUEST_DOCUMENT 
    where 
    DOCUMENT_ID=a.DOCUMENT_ID and REQUEST_ID=3)
    from 
    DOCUMENT_TYPES a
    where 
    DOCUMENT_ID in 
    (select DOCUMENT_ID from CLEARANCE_DOCUMENTS dt 
    where 
    dt.CLEARANCE_ID=
    (SELECT R.CLEARANCE_TYPE FROM CLEARANCE_REQUEST R 
    WHERE 
    R.REQUEST_ID=3)) 

i write this Query in linq but not work

 var list = (from r in context.CLEARANCE_REQUEST
                        where r.REQUEST_ID == 3
                        join cd in context.CLEARANCE_DOCUMENTS on r.CLEARANCE_TYPE equals cd.CLEARANCE_ID
                        join dt in context.DOCUMENT_TYPES on cd.DOCUMENT_ID equals dt.DOCUMENT_ID into outer
                        from t in outer.DefaultIfEmpty()
                        select new
                                   {
                                        r.REQUEST_ID,
                                        cd.CLEARANCE_ID,
                                        t.DOCUMENT_ID,
                                        t.DOCUMENT_NAME,
                                        is_set=(from b in context.CLEARANCE_REQUEST_DOCUMENT where 
                                                    b.REQUEST_ID==r.REQUEST_ID && b.DOCUMENT_ID==t.DOCUMENT_ID
                                                    select new{b.IS_ORGINAL})
                                   }

                       ).ToList();

I want convert this Query to LINQ. Please help me. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:56:17+00:00Added an answer on June 10, 2026 at 9:56 pm

    There is no need to manually join objects returned from an Entity Framework context.

    See Why use LINQ Join on a simple one-many relationship?

    If you use the framework as intended your job will be much easier.

    var result = var clearanceTypes = context.CLEARANCE_REQUEST
        .Single(r => r.REQUEST_ID == 3)
        .CLEARANCE_DOCUMENTS
        .SelectMany(dt => dt.DOCUMENT_TYPES)
        .Select(a => new 
        {
            DocumentType = a,
            IsOriginal = a.CLEARANCE_REQUEST_DOCUMENT.is_original
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have one table sql server like below , from that table i want
I have a table in SQL that links to itself through parentID. I want
I have a table in SQL Server, where i want inserts to be added
I have table with data 1/1 to 1/20 in one column. I want the
I have table in SQL-Server with 10 columns, one of is IP varchar(39). I
I have a table in SQL Server 2005 SP4; in which one of the
I have SQL table in which I have column and Probability . I want
i have sql table which has partitions. I recently created one partition. Even if
I have a table in sql, I use this statement to make a select:
I have a table on Sql: ID User Observation ======================================== 1 John This is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.