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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:30:57+00:00 2026-05-23T11:30:57+00:00

Does entity framework return the same object reference if I query the logically (in

  • 0

Does entity framework return the same object reference if I query the “logically” (in database) same object from different places.

For example, I queried customer with name Joe Black, (and assume for now I know that there’s only one Joe Black in the database.)
Customer c = select ... blabla where ... Name == Joe Black...; and in somewhere else in the code, I queried Customer c2 = select... where.. ID==5 where 5 is the ID of Joe Black. I know that in the database they map to the same object, but DO they also map to the same object in code level? So does c1 equal to c2? I have lists to merge and check for logical equality of the objects (I cannot access the database for now) and I was wondering whether Entity Framework objects will play nicely with it or should I write my custom comparer classes.

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

    Most ORMs, including Entity Framework and NHibernate, use the Identity Map Pattern to ensure there is only a single instance of a given entity per primary key. The identity map is scoped by the context, so two different contexts will create two objects which refer to the same entity. It is a good practice to have entities implement IEquatable, including overrides for equality operators so that ‘==’ or ‘!=’ will work. This is more involved than what one might think. Take a look here for an example.

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

Sidebar

Related Questions

Dumb question I'm sure, but why does Entity Framework EntityDataSource object require the where
Ok I've seen this question Entity Framework: Generate Database From Model removes Stored Procedures
Any ideas why does the entity framework in LINQ gives following strange error: Unable
Does anyone know of any good tutorials on ADO.NET Entity Framework? There are a
The .NET Entity framework is giving me the following error: The table/view 'Foo.dbo.vwFoo' does
When using the Entity Framework, does ESQL perform better than Linq to Entities? I'd
What does one loose by creating POCO using T4 templates in entity framework 4.0?
Someone has an answer to this missing feature in Entity Framework. Does anyone have
I just recently switched out our repository and context from Linq-to-SQL to Entity Framework
Does ADO.NET Entity Framework have a construct similar to LINQ to SQL's GetTable? I'm

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.