Esempio n. 1
0
        public ActionResult Index()
        {
            var ctx = new WebDbContext();
            var companies = ctx.Set<Company>().ToList();

            return View();
        }
Esempio n. 2
0
        public IEnumerable <T> GetAll(string[] includes = null)
        {
            //HANDLE INCLUDES FOR ASSOCIATED OBJECTS IF APPLICABLE
            if (includes != null && includes.Count() > 0)
            {
                var query = dataContext.Set <T>().Include(includes.First());
                foreach (var include in includes.Skip(1))
                {
                    query = query.Include(include);
                }
                return(query.AsQueryable());
            }

            return(dataContext.Set <T>().AsQueryable());
        }
Esempio n. 3
0
 public CompanyRepository()
 {
     _context  = new WebDbContext();
     _entities = _context.Set <T>();
 }
Esempio n. 4
0
        public async Task Create(TEntity entity)
        {
            await context.Set <TEntity>().AddAsync(entity);

            await context.SaveChangesAsync();
        }
Esempio n. 5
0
 public Repository(WebDbContext _dbContext)
 {
     dbContext = _dbContext;
     DbSet     = dbContext.Set <TEntity>();
 }