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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:32:37+00:00 2026-06-11T14:32:37+00:00

I am going to trash Entity Framework 5! I have spent two days to

  • 0

I am going to trash Entity Framework 5! I have spent two days to find solution from web but found nothing!

I tried a simple left join from table Artworks and EndValidities with the input IDFondazione as 2620

var query = from art in db.Artworks
  join endVal in db.EndValidities.DefaultIfEmpty() 
  on art.ID_Dtsl equals endVal.IDdtsl 
  where art.ID_Cdgs == IDFondazione
  select new SchedaOpera()
  {
    Cdscheda = art.Cdscheda,
    Confirmed = art.FGconfermata,
    DSimmagine = art.DSimmgine,
    Dtsf = art.Dtsf,
    Dtsi = art.Dtsi,
    Dtsl = endVal != null ? endVal.Dtsl : "",
    Iscr = art.Iscr,
    Misa = art.Misa,
    Ldcn = art.Ldcn,
    Ldcs = art.Ldcs,
    Misd = art.Misd,
    Misl = art.Misl,
    Misn = art.Misn,
    Misp = art.Misp,
    Miss = art.Miss,
    Pvcc = art.Pvcc,
    Pvcp = art.Pvcp,
    Sgtt = art.Sgtt
  };

The marvellous entity framework continues to produce

SELECT [Extent1].[ID_Dtsl] AS [ID_Dtsl], [Extent1].[CDscheda] AS [CDscheda], 
[Extent1].[FGconfermata] AS [FGconfermata], 
[Extent1].[DSimmagine] AS [DSimmagine], 
[Extent1].[DS_DTSF] AS [DS_DTSF], 
[Extent1].[DS_DTSI] AS [DS_DTSI], 
CASE WHEN (cast(1 as bit) <> cast(0 as bit)) THEN [Extent2].[DSdtsl] ELSE N'_' END AS [C1], 
[Extent1].[DS_ISCR] AS [DS_ISCR], 
[Extent1].[NR_MISA] AS [NR_MISA], 
[Extent1].[DS_LDCN] AS [DS_LDCN], 
[Extent1].[DS_LDCS] AS [DS_LDCS], 
[Extent1].[NR_MISD] AS [NR_MISD], 
[Extent1].[NR_MISL] AS [NR_MISL], 
[Extent1].[NR_MISN] AS [NR_MISN], 
[Extent1].[NR_MISP] AS [NR_MISP], 
[Extent1].[NR_MISS] AS [NR_MISS], 
[Extent1].[FGpubblicata] AS [FGpubblicata], 
[Extent1].[DS_PVCC] AS [DS_PVCC], 
[Extent1].[DS_PVCP] AS [DS_PVCP], 
[Extent1].[DS_SGTT] AS [DS_SGTT]
FROM  [dbo].[TPD_OPERE] AS [Extent1]
INNER JOIN [dbo].[TSA_DTSL] AS [Extent2] ON [Extent1].[ID_Dtsl] = [Extent2].[IDdtsl]
WHERE [Extent1].[CD_CDGS] = '2620'
  • 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-11T14:32:38+00:00Added an answer on June 11, 2026 at 2:32 pm

    DefaultIfEmpty in Entity Framework only works on navigation properties. Otherwise you should use GroupJoin, which in comprehensive syntax is achieved by join … into. See this excellent post for more details.

    So your query could be (GroupJoin):

    from art in db.Artworks
    join endVal in db.EndValidities on art.ID_Dtsl equals endVal.IDdtsl
    into g // can be any name
    where art.ID_Cdgs == IDFondazione
    ...
    

    The difference is the statement selects art objects and a collection of endVal objects per art object. So the Dtsl property should be a Select on endVal.Dtsl, producing a collection of Dtsl values. The collection can be empty (zero elements), which represents the outer join.

    Or, if there is navigation property Artwork.EndValidities:

    from art in db.Artworks
    from endVal in art.EndValidities.DefaultIfEmpty() 
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Going mad now. I have a MVC solution that i've upgraded from MVC 1
Going through Javascript documentation, I found the following two functions on a Javascript object
Going to play with an Overlay from YUI 2 and IE6 (old stuff, but
Going from Rails to ASP.net has been quite a pain. But I was wondering
Going back to the basics. I want to have two forms to view a
Going thru all the documentation and results from google, I can't find or figure
Going through happstack-lite tutorial : we build functions that have return type of ServerPart
Going from the example given here... http://ericswann.org/blog/archive/2009/04/06/linq-to-sql-datacontext-provider-revisited.aspx I'm trying to use the datacontext between
Going round in circles here i think. I have an activity called Locate; public
Going through the microsoft authentication tutorial listed here they have you create a master

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.