public async Task AddAsync(T entity) { using var context = new GeoToDoDbContext(); await context.AddAsync(entity); await context.SaveChangesAsync(); }
public async Task <List <AppRole> > GetRolesByEmail(string email) { using var context = new GeoToDoDbContext(); return(await context.AppUsers.Join(context.AppUserRoles, u => u.Id, ur => ur.AppUserId, (user, userRole) => new { user = user, userRole = userRole }).Join(context.AppRoles, two => two.userRole.AppRoleId, r => r.Id, (twoTable, role) => new { user = twoTable.user, userRole = twoTable.userRole, role = role }).Where(I => I.user.Email == email).Select(I => new AppRole { Id = I.role.Id, Name = I.role.Name }).ToListAsync()); }
public async Task UpdateAsync(T entity) { using var context = new GeoToDoDbContext(); context.Update(entity); await context.SaveChangesAsync(); }
public async Task <T> GetByIdAsync(int id) { using var context = new GeoToDoDbContext(); return(await context.FindAsync <T>(id)); }
public async Task <T> GetByFilter(Expression <Func <T, bool> > expression) { using var context = new GeoToDoDbContext(); return(await context.Set <T>().FirstOrDefaultAsync(expression)); }
public async Task <List <T> > GetAllByFilter(Expression <Func <T, bool> > expression) { using var context = new GeoToDoDbContext(); return(await context.Set <T>().Where(expression).ToListAsync()); }
public async Task <List <T> > GetAllAsync() { using var context = new GeoToDoDbContext(); return(await context.Set <T>().ToListAsync()); }