Some questions come to mind when using the ObjectContext containing your entities.
First, what should the lifetime of an ObjectContext be? Is it like a connection object that should be opened and then closed quickly? When working with your entities, would it be more common for your entities to be attached or detached from an ObjectContext? For example, on your ASP.NET page or Windows Form, would you have an ObjectContext object and your business entities? Or are these objects manipulated in a lower business layer (as Danny Simmons suggests here)?
This thread discusses these issues.
Related to this (and mentioned in the above links) is the idea of abandoning the changes to a set of entities. At this point, there is no RejectChanges method on the ObjectContext. So how do you reset your entites back to a known state? This thread discusses options for accomplishing this.
Rick Strahl has some good related thoughts.
Leave a Reply