public List <T> GetAll() { using (var context = DbContextCreator.Create()) { return(context.Set <T>().ToList()); } }
public int GetCount() { using (var context = DbContextCreator.Create()) { return(context.Set <T>().Count()); } }
public T GetByPK(K key) { using (DbContext context = DbContextCreator.Create()) { return(context.Set <T>().Find(key)); } }
public void Delete(T entity) { using (var context = DbContextCreator.Create()) { context.Entry(entity).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); } }
public void Insert(T entity) { using (var context = DbContextCreator.Create()) { context.Set <T>().Add(entity); context.SaveChanges(); } }
public K GetMaxKey() { using (var context = DbContextCreator.Create()) { var query = context.Set <T>() .OrderByDescending(KeySelector) .Select(KeySelector); return(query.FirstOrDefault()); } }