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

  • Home
  • SEARCH
  • 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 9000703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:20:37+00:00 2026-06-16T00:20:37+00:00

I have trying to convert this sql query to Linq to lambda and i

  • 0

I have trying to convert this sql query to Linq to lambda and i have no success i only have the records that are in the table places that match the id on the table requireddocuments i want the nulls too. The sql query works fine but the lambda doesn’t

SQL Query.

  SELECT Document, Place, Record
   FROM RequiredApplicationDocuments LEFT OUTER JOIN Places ON
     RequiredApplicationDocuments.Id = Places.RequiredApplicationDocumentId
       WHERE Places.SecondPlaceId = 4 OR Places.SecondPlaceId IS NULL

Lambda

Database.RequiredApplicationDocuments.Join(Database.Placess, 
            ra => ra.Id, fa => fa.RequiredApplicationDocumentId, (fa, ra) =>
            new {Places = fa, RequiredApplicationDocument = ra}).DefaultIfEmpty().toList().Select(fa => new Places
                           {
                  FileName = fa.RequiredApplicationDocument.FileName,
                  LoanApplicationId = fa.RequiredApplicationDocument.LoanApplicationId,
                  Name = fa.RequiredApplicationDocument.Name,
                  RequiredApplicationDocument = fa.RequiredApplicationDocument.RequiredApplicationDocument,
                  Id = fa.Places.Id,
                  CreationDate = fa.RequiredApplicationDocument.CreationDate,
                  Contents = fa.RequiredApplicationDocument.Contents,
                  RequiredApplicationDocumentId = fa.RequiredApplicationDocument.RequiredApplicationDocumentId,
                  LoanApplication = fa.RequiredApplicationDocument.LoanApplication,
                  Type = fa.RequiredApplicationDocument.Type 
            }).AsQueryable();
  • 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-16T00:20:37+00:00Added an answer on June 16, 2026 at 12:20 am

    use GroupJoin

    This is more targeted to you SQL than to your LINQ

            var res = RequiredApplicationDocuments.GroupJoin(Places,
                p => p.Id,
                d => d.RequiredApplicationDocumentId,
                (d, places) => new
                {
                    Document = d,
    
                    Place = places.Where(p => p.SecondPlaceId == 4).FirstOrDefault(),
    
                    // if don't want to exclude documents with "non-4" places only, 
                    // remove this and last where clause
                    // but this is what your SQL does
                    HasNoPlaces = places.Count() == 0 
    
                }).Where(r => r.HasNoPlaces || r.Place != null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query in SQL Server that I am trying to convert to
I have a working sql query that I have been trying to convert to
Have the following (non-straightforward) T-SQL query, which i'm trying to convert to LINQ (to
I have a SQL Statement that I am trying to convert to a LINQ
I have a project that I am trying to convert to OSGi. However, this
I'm trying to convert a standard SQL query to a LINQ to SQL query.
I am trying to convert this SQL statement into LINQ SELECT a.UserId, b.Date, a.Value1
I'm trying to convert a Linq query to SQL. My Linq query looks like
I'm in SQL 2005 and I'm trying to convert this Cursor into something that
I have a SQL query that I execute like this with an SQLAlchemy engine:

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.