コード例 #1
0
ファイル: CarBrandRepos.cs プロジェクト: V1zz/EFExamples
        //    public CarBrandRepos()
        //    {

        //    }
        public void Add(CarBrands carBrand)
        {
            using (var context = new CarShopContext())
            {
                context.CarBrands.Add(carBrand);
                context.SaveChanges();
            }
        }
コード例 #2
0
ファイル: CarBrandRepos.cs プロジェクト: V1zz/EFExamples
 public void Update(CarBrands carBrand)
 {
     using (var context = new CarShopContext())
     {
         var entity = context.CarBrands.Find(carBrand.Id);
         context.Entry(entity).CurrentValues.SetValues(carBrand);
         context.SaveChanges();
     }
 }
コード例 #3
0
ファイル: CarBrandRepos.cs プロジェクト: V1zz/EFExamples
 public IEnumerable <CarBrands> Find(Expression <Func <CarBrands, bool> > predicate,
                                     Expression <Func <CarBrands, object> > includedProperties = null)
 {
     using (var context = new CarShopContext())
     {
         return(includedProperties != null
             ? context.CarBrands.Include(includedProperties).Where(predicate).ToArray()
             : context.CarBrands.Where(predicate).ToArray());
     }
 }
コード例 #4
0
ファイル: CarBrandRepos.cs プロジェクト: V1zz/EFExamples
 public void Remove(Guid id)
 {
     using (var context = new CarShopContext())
     {
         CarBrands carBrand = this.Find(x => x.Id == id).FirstOrDefault(); //this.Get(Id);
         using (var db = this.GetContext())
         {
             // db.CarBrands.Remove(carBrand); -
             // We can't use remove as we retrieved entity in other db context that is already closed
             // Rather we can attach entry to a current dbContext and mark it as deleted
             db.Entry(carBrand).State = EntityState.Deleted;
             db.SaveChanges();
         }
     }
 }
コード例 #5
0
 public ShopRespository(CarShopContext context) : base(context)
 {
 }
コード例 #6
0
 public UserRepo(CarShopContext context)
 {
     db = context;
 }
コード例 #7
0
 public CarRepository(CarShopContext carShopContext)
 {
     _carShopContext = carShopContext;
 }
コード例 #8
0
 public UnitOfWork()
 {
     db    = new CarShopContext();
     _repo = new Dictionary <Type, object>();
 }
コード例 #9
0
 public PurchasesController(CarShopContext context)
 {
     _context = context;
 }
コード例 #10
0
 public CarRepository(CarShopContext context) : base(context)
 {
 }
コード例 #11
0
 public ToolsController(CarShopContext context)
 {
     _context = context;
 }
コード例 #12
0
 public RepairRequestsController(CarShopContext context)
 {
     _context = context;
 }
コード例 #13
0
 public PartsController(CarShopContext context)
 {
     _context = context;
 }
コード例 #14
0
 public Repository(CarShopContext con)
 {
     db    = con;
     dbSet = db.Set <T>();
 }