namespace didongexpress.repos
{
public interface IRepository : IDisposable
{
}
public interface IRepository<T> : IRepository where T : class
{
IQueryable<T> Query(Expression<Func<T, bool>> predicate);
List<T> All(Expression<Func<T, bool>> predicate);
T GetById(object id);
T Create(T model);
T Update(T model, List<Expression<Func<T, object>>> updateProperties = null);
T Delete(T model);
T Delete(object id);
}
public class GenericRepository<T> : IRepository<T> where T : class
{
protected bool disposed = false;
protected ExpressDb db = null;
protected DbSet table;
public GenericRepository(ExpressDb db)
{
this.db = db;
}
public IQueryable<T> Query(Expression<Func<T, bool>> predicate)
{
throw new NotImplementedException();
}
public virtual List<T> All(Expression<Func<T, bool>> predicate)
{
throw new NotImplementedException();
}
public virtual T Create(T model)
{
throw new NotImplementedException();
}
public virtual T Delete(object id)
{
throw new NotImplementedException();
}
public virtual T Delete(T model)
{
throw new NotImplementedException();
}
public virtual T GetById(object id)
{
throw new NotImplementedException();
}
public virtual T Update(T model, List<Expression<Func<T, object>>> updateProperties = null)
{
throw new NotImplementedException();
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected void Dispose(bool disposing)
{
if (!disposed)
{
if (disposing)
{
if (db != null)
{
db.Dispose();
db = null;
}
}
disposed = true;
}
}
}
}