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 6757071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:36:09+00:00 2026-05-26T13:36:09+00:00

This linq to ef syntax produces the sql syntax shown below. How can I

  • 0

This linq to ef syntax produces the sql syntax shown below. How can I get it to produce without the CROSS JOIN? The cross join is giving me a ton of extra records.

vehicleList = (from _vehicle in shireyContext.Vehicles
                                   join _statusDescription in shireyContext.StatusDescriptions
                                   on _vehicle.Status equals _statusDescription.StatusId
                                   join _newOptions2 in shireyContext.VehicleOption_New
                                   on _vehicle.StockNo equals _newOptions2.StockNo
                                   where _vehicle.NewOrUsed == NewOrUsed && _vehicle.Model == Model && _newOptions2.Color != null                                       
                                   from _newOptions in shireyContext.VehicleOption_New
                                   select new VehicleDomainEntity
                                   {
                                       StockNo = _vehicle.StockNo,
                                       Year = _vehicle.VehicleYear,
                                       Make = _vehicle.Make,
                                       Model = _vehicle.Model,
                                       Description = _newOptions2.Description,
                                       ExteriorColor = _vehicle.ExteriorColor,
                                       InteriorColor = _vehicle.InteriorColor,
                                       InternetPrice = _vehicle.CodedCost,
                                       ListPrice = _vehicle.ListPrice,
                                       Status = _statusDescription.StatusDescriptionText,
                                       NewOrUsed = _vehicle.NewOrUsed,
                                       Mileage = _vehicle.Mileage,
                                       VIN = _vehicle.VIN
                                   }).ToList();

produces this sql:

 SELECT
Extent2.StatusId AS StatusId,
Extent1.StockNo AS StockNo,
Extent1.VehicleYear AS VehicleYear,
Extent1.Make AS Make,
Extent1.Model AS Model,
Extent3.Description AS Description,
Extent1.ExteriorColor AS ExteriorColor,
Extent1.InteriorColor AS InteriorColor,
Extent1.CodedCost AS CodedCost,
Extent1.ListPrice AS ListPrice,
Extent2.StatusDescriptionText AS StatusDescriptionText,
Extent1.NewOrUsed AS NewOrUsed,
Extent1.Mileage AS Mileage,
Extent1.VIN AS VIN
FROM  dbo.Vehicles AS Extent1
INNER JOIN dbo.StatusDescription AS Extent2 ON Extent1.Status = Extent2.StatusId
INNER JOIN dbo.VehicleOption_New AS Extent3 ON Extent1.StockNo = Extent3.StockNo
CROSS JOIN dbo.VehicleOption_New AS Extent4
WHERE (Extent1.NewOrUsed = 'N') AND (Extent1.Model = 'cts' AND (Extent3.Color IS NOT NULL))
  • 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-05-26T13:36:10+00:00Added an answer on May 26, 2026 at 1:36 pm

    I think you want this

    from _vehicle in shireyContext.Vehicles
    join _statusDescription in shireyContext.StatusDescriptions
    on _vehicle.Status equals _statusDescription.StatusId
    join _newOptions2 in shireyContext.VehicleOption_New into VehicleNew
    on _vehicle.StockNo equals _newOptions2.StockNo
    where _vehicle.NewOrUsed == NewOrUsed && _vehicle.Model == Model && _newOptions2.Color != null
    from _newOptions in VehicleNew
    

    The two lines that are changed are:

     join _newOptions2 in shireyContext.VehicleOption_New into VehicleNew
    

    and

    from _newOptions in VehicleNew
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ora. i've got this linq syntax below that generates the sql below that. the
I am trying to convert this SQL to linq syntax, but I'm having some
I'm having a hard time getting the LINQ-syntax.. How can I do this command
How can I clean up this LINQ Query to use SelectMany in the sql
This Linq to SQL query ... Return (From t In Db.Concessions Where t.Country =
I can't quite figure out why this Linq Statement isn't working as i would
I've been using this nifty LINQ to SQL tool for a data access layer
The following SQL SELECT * FROM customers converted to this in LINQ var customers
I need help re-factoring this legacy LINQ-SQL code which is generating around 100 update
What is the equivalent lambda syntax to this linq query? Dim query = From

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.