public TEntity FirstOrDefault() => _context.Set <TEntity>().FirstOrDefault();
 public BaseRepository()
 {
     _context = new Context.AppContext();
     DbSet    = _context.Set <TEntity>();
 }
Exemplo n.º 3
0
        public virtual IQueryable <T> GetAll()
        {
            IQueryable <T> query = _context.Set <T>();

            return(query);
        }
Exemplo n.º 4
0
 // CONSTRUCTORS
 /// <summary>
 /// Initializes a new instance of <see cref="NonGenericRepository"/>
 /// </summary>
 /// <param name="context">
 /// Data context
 /// </param>
 /// <param name="entityType">
 /// Entity type
 /// </param>
 public NonGenericRepository(Context.AppContext context, Type entityType)
 {
     this.context = context;
     this.dbSet   = context.Set(entityType);
 }
 // CONSTRUCTORS
 /// <summary>
 /// Initialize a new instance of <see cref="GenericRepository{TEntity}"/>
 /// </summary>
 /// <param name="context">Data context</param>
 public GenericRepository(Context.AppContext context)
 {
     this.context = context;
     this.dbSet   = context.Set <TEntity>();
 }