I set up an IDataContext and when i create a data class for an entity, i inherit it from IDataContext.
IDataContext interface has 4 methods.
IQueryable<T> GetAll();
T GetById(long id);
void Add(T entity);
void Delete(T entity);
void Save(T entity);
As you know Delete and Save methods have this structure;
FooEntities db = new FooEntities();
db.DeleteObject(Foo entity);
// or save changes method
db.SaveChanges();
I meant these two methods could be generalized or something...
My question is how and where do you use these two methods.
- Inside of the each data class for an entity
- or another way of using.