public async Task <List <TEntity> > GetAll(int offset, int limit) { using (var dbContext = new raw2Context()) { return(await dbContext.Set <TEntity>().Skip(offset).Take(limit).ToListAsync()); } }
public async Task <TEntity> Get(int id) { using (var dbContext = new raw2Context()) { return(await dbContext.Set <TEntity>().FindAsync(id)); } }
public async Task <TEntity> Update(TEntity entity) { using (var dbContext = new raw2Context()) { dbContext.Entry(entity).State = EntityState.Modified; await dbContext.SaveChangesAsync(); return(entity); } }
public async Task <TEntity> Create(TEntity entity) { using (var dbContext = new raw2Context()) { dbContext.Set <TEntity>().Add(entity); await dbContext.SaveChangesAsync(); return(entity); } }
public void AddSearchHistory(string query, int userId) { Task.Run(() => { using (var context = new raw2Context()) { var searchEntry = new SearchEntry(query, userId); context.SearchEntry.Add(searchEntry); var res = context.SaveChanges(); return(res != 1 ? null : searchEntry); } }); }
public async Task <List <Models.Post> > GetPostAnswers(int id) { using (var context = new raw2Context()) { return(await context.Post .Where(p => p.ParentId == id) .Include(p => p.Author) .Include(p => p.Comment) .ThenInclude(c => c.Author) .OrderByDescending(p => p.Score) .ToListAsync()); } }
public async Task <List <TEntity> > GetAll(int offset, int limit, TOptions options) { using (var dbContext = new raw2Context()) { var x = dbContext.Set <TEntity>().Skip(offset).Take(limit); foreach (var model in options.IncludedModels) { x = x.Include(model); } return(await x.ToListAsync()); } }
public async Task <Models.Post> GetComplete(int id) { using (var context = new raw2Context()) { return(await context.Post .Include(p => p.PostTag) .ThenInclude(pt => pt.Tag) .Include(p => p.PostLinkFromPost) .ThenInclude(pl => pl.ToPost) .Include(p => p.Author) .Include(p => p.Comment) .ThenInclude(c => c.Author) .FirstOrDefaultAsync(p => p.PostId == id)); } }
public async Task <bool> Delete(int id) { using (var dbContext = new raw2Context()) { var entity = await dbContext.Set <TEntity>().FindAsync(id); if (entity == null) { return(false); } dbContext.Set <TEntity>().Remove(entity); await dbContext.SaveChangesAsync(); return(true); } }
public CommentRepository(raw2Context dbContext) : base(dbContext) { DbContext = dbContext; }
public Repository(raw2Context dbContext) { DbContext = dbContext; }
public SearchRepositoryTests() { context = new raw2Context(); }
public SearchRepository(raw2Context dbContext) : base(dbContext) { DbContext = dbContext; }
public UserRepository(raw2Context dbContext) : base(dbContext) { DbContext = dbContext; }
public PostRepository(raw2Context dbContext) : base(dbContext) { DbContext = dbContext; }