public T GetEntity(long pLonId) { T lObjEntity = mObjContext.Set <T>().Where(x => x.Removed == false && x.Id == pLonId).FirstOrDefault(); if (lObjEntity == null) { throw new Exception("No se encontró el registro."); } return(lObjEntity); }
public IQueryable <TEntity> GetInclude(params Expression <Func <TEntity, object> >[] expr) { IQueryable <TEntity> query = db.Set <TEntity>(); expr.ToList().ForEach(x => query = query.Include(x)); return(query); }
/// <summary> /// Adiciona item no banco utilizando o contexto do entity framework. Necessário utilizar o método Commit para confirmar a transação. /// </summary> /// <param name="entity">Entidade a ser adicionada</param> /// <returns></returns> public T Add <T>(T entity) where T : ModelBase { //var _DbSet = Context.Set(typeof(T)); var _DbSet = Context.Set <T>(); return((T)_DbSet.Add(entity)); }
public RepositoryBase(IBaseContext context, IBulkWorker <TEntity> bulkWorker) { _bulkWorker = bulkWorker; this.Context = context; this.DbSet = context.Set <TEntity>(); }
public Repository(IBaseContext context) { db = context; dbSet = db.Set <TEntity>(); }
public BaseRepository(IBaseContext context) { _context = context; _dbSet = _context.Set <TEntity>(); }
public IQueryable <T> GetAll <T>(Expression <Func <T, bool> > condition = null) where T : class { return(condition != null?_context.Set <T>().Where(condition) : _context.Set <T>()); }