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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:56:12+00:00 2026-05-30T13:56:12+00:00

In a database I have Reservations and OldReservations tables, where OldReservations is a copy

  • 0

In a database I have Reservations and OldReservations tables, where OldReservations is a copy ( of Reservations table ) and is used to store old reservations. Here are the steps I did to create TPC inheritance:

1) I derived OldReservation entity from Reservations entity
2) I removed the overlapping properties from OldReservations entity
3) I’ve then mapped the OldReservations table fields in the XML of the EDMX file

But when I run the folllowing query, the generated sql uses LEFT OUTER JOIN, which doesn’t make sense, since it means that query will only return rows from OldReservations table where Reservations.ReservationID == OldReservations.ReservationID. From the articles I’ve read it seems that the above query should use an UNION operator and not the LEFT OUTER JOIN:

        var reservations = context.Reservations;
        foreach (var item in reservations);

Generated SQL:

SELECT CASE
         WHEN (NOT (([Project1].[C1] = 1)
                    AND ([Project1].[C1] IS NOT NULL))) THEN '0X'
         ELSE '0X0X'
       END                         AS [C1],
       [Extent1].[ReservationID]   AS [ReservationID],
       [Extent1].[ReservationDate] AS [ReservationDate],
       [Extent1].[ContactID]       AS [ContactID],
       [Extent1].[EventID]         AS [EventID],
       [Extent1].[RowVersion]      AS [RowVersion]
FROM   [dbo].[Reservations] AS [Extent1]
       LEFT OUTER JOIN (SELECT [Extent2].[ReservationID] AS [ReservationID],
                               cast(1 as bit)            AS [C1]
                        FROM   [dbo].[OldReservations] AS [Extent2]) AS [Project1]
         ON [Extent1].[ReservationID] = [Project1].[ReservationID]

TPC select query using left outer join doesn’t make sense, so what am I doing wrong when creating TPC inheritance?

thank you

  • 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-30T13:56:12+00:00Added an answer on May 30, 2026 at 1:56 pm

    That’s how TPC is supposed to work. Reservation is a concrete type, so the properties in Reservation are stored in the Reservations table. OldReservation is also a concrete type, so the properties in OldReservation that aren’t already mapped are stored in the OldReservations table.

    What you want is similar, but not quite the same. Make Reservation an abstract type and rename it to ReservationBase. Then create a derived type Reservation. Now OldReservation no longer derives from a concrete type, so all of OldReservation own properties and inherited properties will map to the OldReservations table.

    After that, yourContext.ReservationBases can be used to get both Reservations and OldReservations, and that should use a UNION (ALL).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tables in my database: reservations , events and users . I
I have database with multiple tables in Microsoft SQL Server with schema in tables
i have database table like this +-------+--------------+----------+ | id | ip | date |
I have database, and in one the tables I need change the values of
i have DataBase function that calculate distance by coordinates CREATE OR REPLACE FUNCTION distance(lat1
My database table have a Timestamp column named as inTime and i am using
I have a table maintaining record of all reservations made. Now the start date
I have two database say A and B . A have a1 table having
My database have got 4 table : users id username images id user_id image
Why do some ecommerce database have tables: product product_variant Why not only one product

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.