How to get a reference to superior ObjectContext from EntityObject class?
A:
Only way you can do it is via a hack using relationships, and an entity that is not detached. See below.
YourEntity someEntity = null;
RelationshipManager relationshipManager = ((IEntityWithRelationships)someEntity ).RelationshipManager;
IRelatedEnd relatedEnd = relationshipManager.GetAllRelatedEnds().FirstOrDefault();
ObjectQuery getContext = relatedEnd.CreateSourceQuery() as ObjectQuery;
YoutObjectContext c1 = (YourObjectContext)getContext .Context;
Good luck with it. If you use the code above i recommend protecting it with null checks.
Nix
2010-03-25 16:11:44
A:
Have a look at the following link:
It is like the way that Nix mentioned as an extenxtion to the entity object.
Reza
2010-04-30 14:16:10