I'm using “ADO.NET Unit Testable Repository Generator" (described here) to generate the entity classes. This T4 template automatically generates the following classes, apart from the classes for the database objects:
- <MyEntities>.cs - The functional concrete object context
- <MyEntities>BaseRepositoryTest.cs
- <MyEntities>Mock.cs - The concrete mock context object that implements the context's interface.
- <MyEntities>Mock.ObjectSet.cs
- <MyModelRepository>.Context.cs
- <MyEntities>PartialRespository.cs
- I<MyEntities>.cs - The interface for the specialised object context.
I am not completely sure what some of these classes are for.
I am using a manager class that performs all database access/update operations.
// Contains all Methods that access the database
public class DataManager
{
private IMyEntities _context;
public DataManager()
: this(new MyEntities())
{
}
public bool AddOrder(Order order)
{
_context.Orders.AddObject(order);
_context.SaveChanges();
}
...
}
i want to check for concurrency exceptions when I call _context.SaveChanges()
. Ideally, I would like to call _context.Refresh()
in case of a concurrency issue. However, the autogenerated ObjectContext class IMyEntities
does have a method like ObjectContext.Refresh()
What am I doing wrong? How can I call Refresh()?