public static bool Insert <T>(T model) where T : class { BookShopContext db = new BookShopContext(); db.Set <T>().Add(model); return(db.SaveChanges() > 0); }
public Repository(BookShopContext bookShopContext) { _dbContext = bookShopContext; _table = _dbContext.Set <T>(); }
public Repository(BookShopContext context) { this.set = context.Set <T>(); this.context = context; }
public static List <T> FindAll <T>(Expression <Func <T, bool> > expression) where T : class { BookShopContext db = new BookShopContext(); return(db.Set <T>().Where(expression).ToList()); }
public static bool Any <T>(Expression <Func <T, bool> > expression) where T : class { BookShopContext db = new BookShopContext(); return(db.Set <T>().Any(expression)); }
public static T Find <T>(Expression <Func <T, bool> > expression) where T : class { BookShopContext db = new BookShopContext(); return(db.Set <T>().FirstOrDefault(expression)); }
public static List <T> Select <T>() where T : class { BookShopContext db = new BookShopContext(); return(db.Set <T>().ToList()); }
public BaseRepository(BookShopContext context) { Context = context; DbSet = Context.Set <T>(); }
public GenericRepository(BookShopContext context) { this.context = context; DbSet = context.Set <TEntity>(); }
public IEnumerable <TEntity> GetAll() { var entities = _context.Set <TEntity>().ToList(); return(entities); }
public async Task <int> InsertAsync(T model) { _context.Set <T>().Add(model); return(await _context.SaveChangesAsync()); }