public List <T> GetAll() { using (var context = DbContextCreator.Context()) { return(context.Set <T>().ToList()); } }
public int GetCount() { using (var context = DbContextCreator.Context()) { return(context.Set <T>().Count()); } }
public T GetByPK(K key) { using (var context = DbContextCreator.Context()) { return(context.Set <T>() .Where(IsKey(key)) .FirstOrDefault()); } }
public void Delete(T entity) { using (var context = DbContextCreator.Context()) { context.Entry(entity).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); } }
public void Insert(T entity) { using (var context = DbContextCreator.Context()) { context.Set <T>().Add(entity); context.SaveChanges(); } }
public K GetMaxKey() { using (var context = DbContextCreator.Context()) { var query = context.Set <T>() .OrderByDescending(KeySelector) .Select(KeySelector); return(query.FirstOrDefault()); } }
public T GetByPK(K1 key1, K2 key2, K3 key3) { using (var context = DbContextCreator.Context()) { var query = context .Set <T>() .Where(IsKey(key1, key2, key3)) .Select(x => x); return(query.FirstOrDefault()); } }