I have seen two different approaches for creating generic repositories. What are differences between those two approaches (pros and cons) ? Please diregard difference in the methods because I am interested in difference between
public interface IRepository<T> where T : class
and
public interface IRepository : IDisposable
Is there any difference in functionality, flexibility, unit testing ... ? What will I get or lose ?
Is there any difference how they are registered in Dependency Injection frameworks ?
Option 1
public interface IRepository<T> where T : class
{
T Get(object id);
void Attach(T entity);
IQueryable<T> GetAll();
void Insert(T entity);
void Delete(T entity);
void SubmitChanges();
}
Option 2
public interface IRepository : IDisposable
{
IQueryable<T> GetAll<T>();
void Delete<T>(T entity);
void Add<T>(T entity);
void SaveChanges();
bool IsDisposed();
}