public int Add(T entity)
 {
     using (context = new ReservationContext())
     {
         context.Set <T>().Add(entity);
         context.SaveChanges();
         DbPropertyValues sa      = context.Entry(entity).GetDatabaseValues();
         string           keyName = sa.PropertyNames.First();
         int Id = sa.GetValue <int>(keyName);
         return(Id);
     }
 }
        public IQueryable <T> FindMany(Expression <Func <T, bool> > predicate, IEnumerable <string> IncludeEntities = null)
        {
            using (context = new ReservationContext())
            {
                IQueryable <T> query = context.Set <T>().Where(predicate);
                if (IncludeEntities != null)
                {
                    query = IncludeEntities.Aggregate(query, (current, includePath) => current.Include(includePath));
                }

                return(query.ToList().AsQueryable());
            }
        }
Exemple #3
0
 public async Task <IReadOnlyList <T> > GetAllAsync()
 {
     return(await _dbContext.Set <T>().ToListAsync());
 }