Exemple #1
0
 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();
        }
Exemple #3
0
        public void DeleteAll()
        {
            // Truncate table ConnectedUsers
            var allConnectedUsers = context.Set <ConnectedUser>();

            context.ConnectedUsers.RemoveRange(allConnectedUsers);
            context.SaveChanges();
        }
Exemple #4
0
        public void DeleteAll()
        {
            // Truncate table File
            var allFiles = context.Set <File>();

            context.Files.RemoveRange(allFiles);
            context.SaveChanges();
        }
Exemple #5
0
        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);
        }
Exemple #6
0
 public void DeleteAll()
 {
     var allGroups = context.Set<Group>();
     context.Groups.RemoveRange(allGroups);
     context.SaveChanges();
 }
Exemple #7
0
 public void Insert(T obj)
 {
     context.Set <T>().Add(obj);
     context.SaveChanges();
 }
Exemple #8
0
 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();
 }
Exemple #11
0
 public void Insert(T obj)
 {
     context.Database.EnsureCreated();
     context.Set <T>().Add(obj);
     context.SaveChanges();
 }