public async Task <T> GetByIdAsync(int id) { return(await _context.Set <T>().FindAsync(id)); }
public async Task <T> GetByIdAsync(int id) => await Context.Set <T>().FindAsync(id);
public async Task <T> GetByIdAsync(int id) { return(await _context.Set <T>().FindAsync(id));//we use Set because can be used to query and save instances of T. T will replace with whetever type we're passing }
public void Add(T entity) { _context.Set <T>().Add(entity); }
private static bool IsDbSetEmpty <T>(StoreContext context) where T : class => !context.Set <T>().Any();
/// <summary> /// The method calls SpecificationEvaluator's GetQuery static method and send to it all the specifications as a query. /// </summary> /// <param name="spec">The specifications (conditions) used in a query</param> /// <returns>The query</returns> private IQueryable <T> ApplySpecification(ISpecification <T> spec) { return(SpecificationEvaluator <T> .GetQuery(_context.Set <T>().AsQueryable(), spec)); }
public async Task <IReadOnlyList <T> > GetAllAsync() { return(await _storeContext.Set <T>().ToListAsync()); }
/// <inheritdoc /> public async Task <T> GetByIdAsync(int id) { return(await _storeContext.Set <T>().SingleOrDefaultAsync(p => p.Id == id)); }
public GenericRepository(StoreContext context) { _context = context; _entities = _context.Set <T>(); }
//3-methods: public async Task <T> GetByIdAsync(int id) { return(await _Context.Set <T>().FindAsync(id)); //Set<T>() will be replaced by the Entity we are using in the generic interface, it can be Product, ProductType, ..... }
public async Task <T> GetByIdAsync(int id) { var item = await _context.Set <T>().FindAsync(id); return(item); }
public async Task <T> AddAsync(T entity) { return((await _context.Set <T>().AddAsync(entity)).Entity); }
public async Task <IReadOnlyList <T> > GetAllAsync() => await context.Set <T>().ToListAsync();
public async Task <T> GetByIdAsync(int id) { //Set method creates a DbSet that can be used to query and save instances of T return(await _context.Set <T>().FindAsync(id)); }