Ejemplo n.º 1
0
        public async Task <List <TestData> > CheckSize(TestDataFilter filter)
        {
            await UpdateAvailable();

            var list = _dbContext.Set <TestData>().Where(x => x.ProductSize.ToLower().Equals(filter.ProductSize.ToLower()) && x.isAvailable == Database.Enums.IsInStock.IN_STOCK).ToList();

            return(await Task.FromResult(list));
        }
Ejemplo n.º 2
0
        /* To Delete multiple record at a time :)
         * <param name="predicate"> contains an expression like > where clause OR list */
        public virtual void DeleteWhere(IEnumerable <T> list)
        {
            _dbContext.Set <T>()
            .RemoveRange(list); // directly contain a list of record

            Save();             // save changes
        }
Ejemplo n.º 3
0
Archivo: repo.cs Proyecto: isencher/oio
        /// <summary>
        /// get entity all collection from store
        /// </summary>
        public static List <T> GetAll <dbContext, T>()
            where dbContext : DbContext, new()
            where T : class, IbaseProperties, new()
        {
            #region to get list
            try
            {
                using (var sc = new dbContext())
                {
                    return(sc.Set <T>().ToList());
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
                return(null);

                throw;
            }
            #endregion
        }
Ejemplo n.º 4
0
        public List <T> GetAll()
        {
            using (DbContextTransaction transaction = _dbContext.Database.BeginTransaction())
            {
                try
                {
                    transaction.Commit();
                    var result = _dbContext.Set <T>().ToList();
                    return(result);
                    //var tt = typeof(T);
                    //var Tu = typeof(U);
                    //var ret = _dbContext.Set<U>().AsNoTracking().ToList();

                    //return Mappings.Default.Map<List<T>>(ret);
                }
                catch (Exception ex)
                {
                    WebErrorLog.ErrorInstence.StartErrorLog(ex);
                    transaction.Rollback();
                    return(null);
                }
            }
        }
Ejemplo n.º 5
0
 public GenericRepository(dbContext db)
 {
     this._dbContext = db;
     this._dbSet     = _dbContext.Set <T>();
 }
Ejemplo n.º 6
0
 public BaseRepository(dbContext dbContext)
 {
     _dbContext = dbContext;
     _dbset     = _dbContext.Set <T>();
 }
 public RepositoryBase(dbContext context)
 {
     Context = context;
     DbSet   = context.Set <T>();
 }
Ejemplo n.º 8
0
 public void Create(TEntity entity)
 {
     _context.Set <TEntity>().Add(entity);
     _context.SaveChanges();
 }
Ejemplo n.º 9
0
 public BaseRepository(dbContext context)
 {
     this._context = context;
     this.dbSet    = context.Set <TEntity>();
 }
Ejemplo n.º 10
0
 public BaseModel(dbContext context)
 {
     dbSet        = context.Set <T>();
     this.context = context;
 }
 public void Excluir(T entity)
 {
     ctx.Set <T>().Remove(entity);
 }
Ejemplo n.º 12
0
Archivo: repo.cs Proyecto: isencher/oio
        /// <summary>
        /// get entity all collection include sub collection from store
        /// </summary>
        public static List <T> GetAllwithInclude <dbContext, T>()
            where dbContext : DbContext, new()
            where T : class, IbaseProperties, new()
        {
            #region to get list
            try
            {
                List <T> result = new List <T>();
                var      navs   = withType.GetNaviProps <T>();
                int      n      = navs.Length;

                using (dbContext sc = new dbContext())
                {
                    switch (n)
                    {
                    case 1:
                        result = sc.Set <T>().Include(navs[0]).ToList();
                        break;

                    case 2:
                        result = sc.Set <T>()
                                 .Include(navs[0])
                                 .Include(navs[1])
                                 .ToList();
                        break;

                    case 3:
                        result = sc.Set <T>()
                                 .Include(navs[0])
                                 .Include(navs[1])
                                 .Include(navs[2])
                                 .ToList();
                        break;

                    case 4:
                        result = sc.Set <T>()
                                 .Include(navs[0])
                                 .Include(navs[1])
                                 .Include(navs[2])
                                 .Include(navs[3])
                                 .ToList();
                        break;

                    case 5:
                        result = sc.Set <T>()
                                 .Include(navs[0])
                                 .Include(navs[1])
                                 .Include(navs[2])
                                 .Include(navs[3])
                                 .Include(navs[4])
                                 .ToList();
                        break;

                    default:
                        result = sc.Set <T>().ToList();
                        break;
                    }
                    return(result);
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
                return(null);

                throw;
            }
            #endregion
        }
Ejemplo n.º 13
0
 public async Task <IEnumerable <T> > GetAll()
 {
     return(await context.Set <T>().AsNoTracking().ToListAsync());
 }
Ejemplo n.º 14
0
 public TEntity Get(int Id)
 {
     return(Context.Set <TEntity>().Find(Id));
 }