public IQueryable <TEntity> GetAll() { try { return(_myDBContext.Set <TEntity>()); } catch (Exception) { throw new Exception("Couldn't retrieve entities"); } }
static void Main(string[] args) { using (var db = new PersonContext()) { db.Database.Delete(); //Try to create table DbSet per = db.Set<Person>(); var per1 = new Person { NameId = 1, Name = "James" }; per.Add(per1); int recordsAffected = db.SaveChanges(); Console.WriteLine( "Saved {0} entities to the database, press any key to exit.", recordsAffected); Console.ReadKey(); } }
/// <summary> /// Initializes a new instance of the repository. /// </summary> /// <param name="context">The context upon which the repository is based.</param> public RepositoryBase(PersonContext context) { _context = context; _dbSet = context.Set <TEntity>(); }
public virtual IQueryable <T> getAll() { return(DbContext.Set <T>().Where(x => x.IsDeleted == false)); }
public IEnumerable <Person> GetAllPerson() { return(_context.Set <Person>()); }
public void Add(TEntity entity) { db.Set <TEntity>().Add(entity); }
public IQueryable <PersonEntity> FindBy(Expression <Func <PersonEntity, bool> > predicate) { IQueryable <PersonEntity> query = dbContext.Set <PersonEntity>().Where(predicate); return(query); }
public GenericRepository(PersonContext context) { this.context = context; this.dbSet = context.Set <TEntity>(); }
public IQueryable <T> GetAll() { return(_context.Set <T>()); }