示例#1
0
 public IQueryable <T> FindById(Expression <Func <T, bool> > predicate)
 {
     using (StoreDataContext dataContext = new StoreDataContext())
     {
         return(dataContext.Set <T>().Where(predicate));
     }
 }
示例#2
0
 public T Get(Expression <Func <T, bool> > predicate)
 {
     using (StoreDataContext dataContext = new StoreDataContext())
     {
         return(dataContext.Set <T>().Where(predicate).FirstOrDefault());
     }
 }
示例#3
0
        public virtual async Task <IList <T> > GetAllAsync(string userId)
        {
            using (StoreDataContext dataContext = new StoreDataContext())
            {
                var results = await dataContext.Set <T>().ToListAsync();

                return(results);
            }
        }
示例#4
0
        public virtual async Task <T> GetAsync(Expression <Func <T, bool> > predicate)
        {
            using (StoreDataContext dataContext = new StoreDataContext())
            {
                var result = await dataContext.Set <T>().Where(predicate).FirstOrDefaultAsync();

                return(result);
            }
        }
示例#5
0
        public virtual async Task CreateAsync(T entity)
        {
            using (StoreDataContext dataContext = new StoreDataContext())
            {
                entity.CreatedDateTime = DateTime.Now;
                entity.ModifyDateTime  = DateTime.Now;

                dataContext.Set <T>().Add(entity);
                await dataContext.SaveChangesAsync();
            }
        }
示例#6
0
        public void Create(T entity)
        {
            using (StoreDataContext dataContext = new StoreDataContext())
            {
                entity.CreatedDateTime = DateTime.Now;
                entity.ModifyDateTime  = DateTime.Now;

                dataContext.Set <T>().Add(entity);
                dataContext.SaveChanges();
            }
        }
示例#7
0
 public Repository(StoreDataContext storeDataContext, IConfiguration configuration)
 {
     _storeDataContext = storeDataContext;
     dataset           = _storeDataContext.Set <T>();
     _config           = configuration;
 }
示例#8
0
 public ProdutoRepositoryEF(StoreDataContext ctx) : base(ctx)
 {
     _dbset = ctx.Set <Produto>();
 }
示例#9
0
 public RepositoryEF(StoreDataContext context)
 {
     _context = context;
     _db      = _context.Set <TEntity>();
 }
示例#10
0
 public void Add(T entity)
 {
     _ctx.Set <T>().Add(entity);
     // _ctx.SaveChanges();
 }
 public void Add(T entity)
 {
     _ctx.Set <T>().Add(entity);
     save();
 }
示例#12
0
 public IEnumerable <T> Get()
 {
     _table = _context.Set <T>();
     return(_table.AsNoTracking().ToList());
 }
示例#13
0
 public GenericRepository(StoreDataContext _context)
 {
     this._context = _context;
     _table        = _context.Set <T>();
 }
示例#14
0
 public virtual async Task <IEnumerable <TType> > Get()
 {
     return(await _context.Set <TType>().AsNoTracking().ToListAsync());
 }
示例#15
0
 public EFRepository(StoreDataContext ctx)
 {
     _ctx   = ctx;
     _dbSet = _ctx.Set <TEntity>();
 }
示例#16
0
 public T Obter(int id)
 {
     return(contexto.Set <T>().Find(id));
 }
 public RepositoryEF(StoreDataContext ctx)
 {
     _ctx = ctx;
     _db  = ctx.Set <TEntity>();
 }
示例#18
0
 public T Obter(int id)
 {
     return(_ctx.Set <T>().Find(id));
 }