public Color Get(Expression <Func <Color, bool> > filter) { using (ReCapDemoDbContex1 context = new ReCapDemoDbContex1()) { return(context.Set <Color>().SingleOrDefault(filter)); } }
public List <Color> GetAll(Expression <Func <Color, bool> > filter = null) { using (ReCapDemoDbContex1 context = new ReCapDemoDbContex1()) { return(filter == null?context.Set <Color>().ToList() : context.Set <Color>().Where(filter).ToList()); } }
public Brand Get(Expression <Func <Brand, bool> > filter) { using (ReCapDemoDbContex1 context = new ReCapDemoDbContex1()) { return(context.Set <Brand>().SingleOrDefault(filter)); } }
public void Update(Color entity) { using (ReCapDemoDbContex1 context = new ReCapDemoDbContex1()) { var updatedEntity = context.Entry(entity); updatedEntity.State = EntityState.Modified; context.SaveChanges(); } }
public void Delete(Color entity) { using (ReCapDemoDbContex1 context = new ReCapDemoDbContex1()) { var deletedEntity = context.Entry(entity); deletedEntity.State = EntityState.Deleted; context.SaveChanges(); } }
public void Add(Color entity) { using (ReCapDemoDbContex1 context = new ReCapDemoDbContex1()) { var addedEntity = context.Entry(entity); addedEntity.State = EntityState.Added; context.SaveChanges(); } }
public void Add(Brand entity) { using (ReCapDemoDbContex1 context = new ReCapDemoDbContex1()) { var addedEntity = context.Entry(entity); addedEntity.State = Microsoft.EntityFrameworkCore.EntityState.Added; context.SaveChanges(); } }
public void Add(Car entity) { if (entity.Description.Length > 2 && entity.DailyPrices > 0) { using (ReCapDemoDbContex1 context = new ReCapDemoDbContex1()) { var addedEntity = context.Entry(entity); addedEntity.State = EntityState.Added; context.SaveChanges(); } } else { Console.WriteLine("Girdiginiz değerlere uyan bir araç olamaz."); } }