public IQueryable <Note> Query() { var query = from note in _context.Set <Note>() join ncat in _context.Set <NoteCategory>() .Where(nc => _categories.Any(id => id == nc.CategoryId)) on note.Id equals ncat.NoteId orderby note.CreationDate descending select note; return(query); }
public Note[] Execute() { Note previous = null; Note next = null; IQueryable <Note> query = _context.Set <Note>().Visible(); if (_isNext) { query = query .Where(n => n.Id != _note.Id && n.CreationDate >= _note.CreationDate) .OrderBy(n => n.CreationDate); next = query.FirstOrDefault(); } else { query = query .Where(n => n.Id != _note.Id && n.CreationDate <= _note.CreationDate) .OrderByDescending(n => n.CreationDate); previous = query.FirstOrDefault(); } return(new Note[] { previous, next }); }
public IQueryable <Note> ExtendQuery(IQueryable <Note> notesQuery) { var qextended = from note in notesQuery join nt in _context.Set <NoteTag>() on note.Id equals nt.NoteId where _tags.Contains(nt.TagId) select note; return(qextended); }
/// <summary> /// Asynchronously retrieves an entity by id. If no entity /// matches the id, the result will be null. /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <T> GetByIdAsync(int id) { var result = await _context .Set <T>() .Where(t => t.Id == id) .FirstOrDefaultAsync(); return(result); }
public BaseRepository(NexusContext context) { _nexusContext = context; _dbset = _nexusContext.Set <TEntity>(); }