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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:19:06+00:00 2026-06-03T02:19:06+00:00

I write a layered .NET 4.0 application. The data layer is implemented using the

  • 0

I write a layered .NET 4.0 application. The data layer is implemented using the Entity Framework, and there are repositories that provide the entity instances to the caller, i.e., the business layer. When the entity framework is asked for a certain entity twice (e.g. by key), it will return the same instance, so changes I make to the entity will be reflected in other places the entity is used. It is not really a caching functionality though, since there is no expiration policy, and performance does not seem to be improved much since the entity framework will still query the database, at least in many cases. The point is simply to make sure that there is only one instance (per context) of each entity.

In the business layer, the entities are mapped to business objects which may differ in structure from the entities. Again, like the repositories in the data layer, there are centralized points of access to obtain instances of the business objects. My goal now is, to have the same functionality that the entity framework provides, meaning “always returning the same instance for a certain object”, in the business layer. I would like to make sure, that every access to a certain business object anywhere in the application will work on the same instance.

BEGIN EDIT

Context awareness is important! Similarly to the entity framework, the uniqueness of each business object instance should be provided on a per context base, not strictly over the whole application. In the business layer there is also the notion of a context, and each context should have its own instance of each business object. This instance should be reused everywhere the context is used.

Also I am looking for a solution, that needn’t be implemented for every single business object class. There are potentially hundreds of them. I would prefer a solution in framework code, that is as transparent as possible to someone implementing a repository. The entity framework itself also doesn’t know about specific entity types, still the entity framework is capable of providing this functionality transparent to an entity model developer.

END EDIT

My questions are:

  • Is there a name for this “only one instance per object” behavior? What would be the Google search term?
  • Are there references, guidelines or best practices, or is there even a design pattern dealing with this issue?
  • Are there classes in .NET that are helpful for writing such functionality, or even provide it completely?

Thanks and regards,
Peter.

  • 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-03T02:19:08+00:00Added an answer on June 3, 2026 at 2:19 am

    Yes it has a name. It is called Identity Map pattern and generally it is just a dictionary of object key / object pairs.

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

Sidebar

Related Questions

I'm using the Entity Framework 4.1 and ASP.Net MVC 3 for my application. MVC
I write a c++ windows application (A), that uses LogonUser, LoadUserProfile and ImpersonateLoggedOnUser to
My problem is multi-layered. I wanted to write a windows service that executes a
Write an application that inputs one number consisting of FIVE digits from the user,
I am trying to write my first true multi layered application and I was
I know how to make my own application transparent using Layered Windows but I
write a script that takes two optional boolean arguments,--verbose‚ and ‚--live, and two required
I write programs used internally by our company. I've created several support DLLs that
i write some utility class but how to get name ? Can that send
In Perl if I want to have a multi-layered hash, I would write: $hash_ref->{'key1'}->{'key2'}='value';

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.