Beispiel #1
0
        public async Task <T> CreateAsync(T entity)
        {
            var result = (await context.Set <T>().AddAsync(entity)).Entity;

            context.SaveChanges();
            return(result);
        }
Beispiel #2
0
 public GenericRepository(TheaterDbContext context)
 {
     _context = context;
     _table   = context.Set <T>();
 }
Beispiel #3
0
 public void Create(T entity)
 {
     entity.CreateTime  = DateTime.UtcNow;
     entity.UpdatedTime = DateTime.UtcNow;
     _context.Set <T>().Add(entity);
 }
Beispiel #4
0
 public TEntity Get(int id)
 {
     return(Context.Set <TEntity>().Find(id));
 }