Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        /// <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));
        }
Пример #4
0
 public RepositoryBase(IBaseContext context, IBulkWorker <TEntity> bulkWorker)
 {
     _bulkWorker  = bulkWorker;
     this.Context = context;
     this.DbSet   = context.Set <TEntity>();
 }
Пример #5
0
 public Repository(IBaseContext context)
 {
     db    = context;
     dbSet = db.Set <TEntity>();
 }
Пример #6
0
 public BaseRepository(IBaseContext context)
 {
     _context = context;
     _dbSet   = _context.Set <TEntity>();
 }
Пример #7
0
 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>());
 }