예제 #1
0
 public async Task UpdateAsync <TId>(TId id, T entity) where TId : IComparable
 {
     using (var context = new SchoolDB())
     {
         UpdateGraph(context, entity);
         await context.SaveChangesAsync();
     }
 }
예제 #2
0
        public async Task <T> CreateAsync(T entity)
        {
            using (var context = new SchoolDB())
            {
                entity = DbSet(context).Add(entity);
                await context.SaveChangesAsync();

                return(entity);
            }
        }
예제 #3
0
 public async Task DeleteAsync <TId>(TId id) where TId : IComparable
 {
     using (var context = new SchoolDB())
     {
         Guid userId = Guid.Parse(id.ToString());
         var  entity = DbSet(context).SingleOrDefault(x => CompareId(id, x));
         if (entity != null)
         {
             DbSet(context).Remove(entity);
             await context.SaveChangesAsync();
         }
     }
 }