New Posts New Posts RSS Feed: EntityAspect.Wrap always returns the same instance
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

EntityAspect.Wrap always returns the same instance

 Post Reply Post Reply
Author
WardBell View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Mar-2009
Location: Emeryville, CA,
Posts: 338
Post Options Post Options   Quote WardBell Quote  Post ReplyReply Direct Link To This Post Topic: EntityAspect.Wrap always returns the same instance
    Posted: 13-Dec-2011 at 10:05am
The question as received:

Do repeated calls to EntityAspect.Wrap() for a POCO return the same EntityAspect instance? I'm thinking it must, but it's not clear from the documentation.

 

Also, I assume that if you implement IHasPocoEntityAspect, it grabs the EntityAspect from there. The doc makes it sound like to access the EntityAspect on a POCO, it's either EntityAspect.Wrap() or IHasPocoEntityAspect. With the last paragraph you can kinda infer that the two work in conjunction, but it's not spelled out.

The answer:

EntityAspect.Wrap will always return the same EntityAspect instance for a given entity, regardless of whether a it is a regular EF-mapped entity or a poco entity.

 

If you implement IHasPocoEntityAspect then this provides the ‘backing’ for the EntityAspect for a given entity, otherwise the relation between the entity and its EntityAspect is stored in a global WeakRefDictionary.

 

The EntityAspect.Wrap method observes these distinctions and responds accordingly.

 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down