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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:37:10+00:00 2026-05-20T11:37:10+00:00

I use Linq To Entities to get 2 objects m1 & m2. And I

  • 0

I use Linq To Entities to get 2 objects m1 & m2.
And I don’t understand why 2 different objects reference the SAME Template table.

I suspect that the reason due to the connection between MConfigOnPage1, MConfigOnPage2 with MConfiguration. Maybe it should be splitted somehow?

I attached my ERD and the code.

I’ll be grateful for explanation why this happens?

Thank you

var cxt = new Entities();
//this returns MConfiguration with Id=19
var m1 = (from mop in cxt.MConfigOnPage1
          where mop.SiteMapId == 15 && mop.HolderId == 13                                         
          select mop.MConfiguration).FirstOrDefault();
//this returns MConfiguration with Id=40    
var m2 = (from mop in cxt.MConfigOnPage2
          where mop.SiteMapId == 15 && mop.HolderId == 1                                         
          select mop.MConfiguration).FirstOrDefault();
  
var t1 = m1.Holder.Template;
var t1.Code = 13;
var t2 = m2.Holder.Template;
//I expect that **t2.Code** to be 0, but it equals 13
//This behavior tells me that m1 & m2 reference the same Template object, 
//   BUT shouldn't m1 & m2 to have their own Template objects?

ERD

SQL-ERD
MConfiguration table data

MConfiguration_Content

Holder table data ____________________________________________________________________________ Template table data

Holder_Content _____________________________________ Template_Content

  • 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-20T11:37:11+00:00Added an answer on May 20, 2026 at 11:37 am

    Link to Entities ensures, within a given context, if you fetch the same entity ( by primary key in DB) you will get the same object.

    You will see this same behavior is you selected the row from the template table multiple times. You will always get the same instance back whenever you re-query for any object.

    This gives you performance advantages through caching and prevents multiple edits to the same object in the same context from causing conflicts.

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

Sidebar

Related Questions

Due to the potential differences between Linq-to-Entities (EF4) and Linq-to-Objects, I need to use
I use LINQ to Objects instructions on an ordered array. Which operations shouldn't I
I would like to use Linq to Xml to get a single XElement from
While trying to use LINQ to SQL I encountered several problems. I have table
I will use LINQ-to-SQL when the database is ready and use the entities there
Assuming you can't use LINQ for whatever reason, is it a better practice to
I would like to use Linq to query a bus schedule in my project,
How can I use Linq with Dataset.xsd files? I've looked at Linq-to-Datasets and Linq-to-XSD
Is it possible to use LINQ in win32 DELPHI applications
I decided to use LINQ to SQL in my personal project after hearing lots

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.