public virtual void Add(TEntity obj) { try { _context.Set <TEntity>().Add(obj); _context.SaveChanges(); } catch (Exception ex) { throw ex; } }
public void DeleteAll() { // Truncate table users var allUsers = context.Set <User>(); context.Users.RemoveRange(allUsers); context.SaveChanges(); }
public void DeleteAll() { // Truncate table ConnectedUsers var allConnectedUsers = context.Set <ConnectedUser>(); context.ConnectedUsers.RemoveRange(allConnectedUsers); context.SaveChanges(); }
public void DeleteAll() { // Truncate table File var allFiles = context.Set <File>(); context.Files.RemoveRange(allFiles); context.SaveChanges(); }
public async Task <List <T> > Get <T>(string[] includes = null) where T : Model { List <T> entities = new List <T>(); _context.Lock.WaitOne(); var query = _context.Set <T>().AsQueryable(); if (includes != null) { foreach (var include in includes) { query = query.Include(include); } } entities = await query.ToListAsync(); _context.Lock.ReleaseMutex(); return(entities); }
public void DeleteAll() { var allGroups = context.Set<Group>(); context.Groups.RemoveRange(allGroups); context.SaveChanges(); }
public void Insert(T obj) { context.Set <T>().Add(obj); context.SaveChanges(); }
public Repository(SqliteContext context) { Db = context; DbSet = Db.Set <T>(); _tableName = Db.Model.FindEntityType(typeof(T)).FindAnnotation("Relational:TableName").Value.ToString(); }
protected GenericRepository(SqliteContext context) { _context = context; DbSet = _context.Set <T>(); }
protected virtual void Insert(TEntity obj) { _sqliteContext.Set <TEntity>().Add(obj); _sqliteContext.SaveChanges(); }
public void Insert(T obj) { context.Database.EnsureCreated(); context.Set <T>().Add(obj); context.SaveChanges(); }