Refresh ObjectContext or recreate it to reflect changes made to the database?

The ObjectContext is meant to be used as a Unit of work, so you create one for every business transaction and dispose of it afterwards stackoverflow.com/questions/3194185/ef-a....

The ObjectContext is meant to be used as a Unit of work, so you create one for every business transaction and dispose of it afterwards. stackoverflow.com/questions/3194185/ef-a....

I'm actually using the repository pattern over the ObjectContext, but I thought the UnitOfWork implementation only meant that you're saving the changes only at the end, in this case by calling the SaveChanges method. I didn't know the UnitOfWork pattern specifies that the object must be disposed after doing the work. – scripni Jul 21 '10 at 12:09.

I have a web service that exposes operations to and from a database. I'm using Entity Framework 4 for the DAL. I'm wondering what would be the best way to handle operations to and from the database.

Would it be best not to keep alive an instance of the ObjectContext and instead create one for each operation done to the database? Handle this, but I can't think of another way to keep up with the changes made to the database. If I keep the same context alive, how will it know when data has been modified?

I understand that when querying the database, the ObjectContext just checks if records have been added or deleted, by checking the Primary Key fields (am I correct? Case, I have to explicitly tell it to refresh a particular object, which is not very practical. I'm thinking of a solution where a timestamp column is used, and the objectcontext checks that column for changes.

If that column is modified, it refreshes the data. Is such a solution built inside Entity Framework 4? On how I can always get the latest data from the database without recreating the ObjectContext for each request?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions