public virtual async Task Add <T>(T currentData) where T : class { try { await _context.Set <T>().AddAsync(currentData); await _context.SaveChangesAsync(); } catch (Exception ex) { throw new Exception(ex.Message); } }
public Tablo GetById(int id) { using (var context = new ToDoContext()) { return(context.Set <Tablo>().Find(id)); } }
public void Guncelle(Tablo tablo) { //Güncelleme işlemi gerçekleştiğinde state'in değişeceğini bildirdik. using var context = new ToDoContext(); context.Set <Tablo>().Update(tablo); context.SaveChanges(); }
public void Update(Table table) { using var context = new ToDoContext(); context.Set <Table>().Update(table); context.SaveChanges(); }
public List <Tablo> GetAll() { using (var context = new ToDoContext()) { return(context.Set <Tablo>().ToList()); } }
public void Kaydet(Tablo tablo) { using (var context = new ToDoContext()) { context.Set <Tablo>().Add(tablo); context.SaveChanges(); } }
public void Sil(Tablo tablo) { using (var context = new ToDoContext()) { context.Set <Tablo>().Remove(tablo); context.SaveChanges(); } }
public void Guncelle(Tablo tablo) { using (var context = new ToDoContext()) { context.Set <Tablo>().Update(tablo); context.SaveChanges(); } }
private void SeedZadania(ToDoContext context) { var idUzytkownika = context.Set <Uzytkownik>().Where(u => u.UserName == "*****@*****.**").FirstOrDefault().Id; for (int i = 1; i <= 5; i++) { var zad = new Zadanie() { Id = i, Nazwa = "Zadanie" + i.ToString(), Opis = "Opis zadania" + i.ToString(), Termin = DateTime.Now.AddDays(-i), Status = (((i % 2 + 2) % 2 == 0) ? true : false) }; context.Set <Zadanie>().AddOrUpdate(zad); } context.SaveChanges(); }
public List <T> GetItems(Expression <Func <T, bool> > predicate, params string[] navigationProperties) { List <T> list; var query = _context.Set <T>().AsQueryable(); foreach (string navigationProperty in navigationProperties) { query = query.Include(navigationProperty);//got to reaffect it. } list = query.Where(predicate).ToList <T>(); return(list); }
private void SeedZamowienia(ToDoContext context) { for (int i = 1; i <= 3; i++) { var zam = new Zamowienie() { ZamowienieID = i, KlientID = i, DataZamowienia = DateTime.Now.AddDays(-i), CenaZamowienia = 1000 * i }; context.Set <Zamowienie>().AddOrUpdate(zam); } context.SaveChanges(); }
private void SeedKlienci(ToDoContext context) { for (int i = 1; i <= 5; i++) { var klient = new Klient() { KlientID = i, Nazwa = "darek" + i.ToString(), Addres = "Lodz_" + i.ToString(), Komorka = "12345678" + i.ToString(), DataUrodzenia = DateTime.Now.AddDays(-i - 40), EmailID = "darek" + i.ToString() + "@o2.pl" }; context.Set <Klient>().AddOrUpdate(klient); } context.SaveChanges(); }
public CrudState Update(T entity) { T old = context.Set <T>().Find(entity.Id); if (old != null) { try { entity.UpdateAt = DateTime.Now; //context.Entry(old).CurrentValues.SetValues(entity); return(Save() == ConnectionState.Success ? CrudState.Success : CrudState.ConnectionError); } catch (Exception) { return(CrudState.EntityError); } } else { return(CrudState.NotFound); } }
/// <summary> /// Public constructor to inject dependancies into the repository /// </summary> /// <param name="context">EF context to inject</param> public RDBERepository(ToDoContext context) { this.Context = context; this.DbSet = context.Set <T>(); }
public BaseController(ToDoContext context, IMapper mapper) { _context = context; _mapper = mapper; _DbSet = _context.Set <T>(); }
public Repository(ToDoContext context) { this.context = context; dbset = context.Set <T>(); }
public BaseRepository() { context = new ToDoContext(); dbSet = context.Set <T>(); }
public Tablo GetirIdile(int id) { using var context = new ToDoContext(); return(context.Set <Tablo>().Find(id)); }
public Table GetWithId(int id) { using var context = new ToDoContext(); return(context.Set <Table>().Find(id)); }
public List <Table> GetAll() { using var context = new ToDoContext(); return(context.Set <Table>().ToList()); }
public void Delete(Table table) { using var context = new ToDoContext(); context.Set <Table>().Remove(table); context.SaveChanges(); }
public List <Tablo> GetirHepsi() { //using keywordu parametre aldığı kaynak(burda context) tükendiği zaman içerisindeki kodları garbage collactora gönderir. using var context = new ToDoContext(); return(context.Set <Tablo>().ToList()); }
public List <TEntity> DajSveEntitete() { return(_context.Set <TEntity>().ToList()); }
public Tablo GetirIdile(int id) { // context tükendiğinde bize id değerini getirmesini istedik. using var context = new ToDoContext(); return(context.Set <Tablo>().Find(id)); }
public GenericRepository(ToDoContext _context) { this._context = _context; table = _context.Set <T>(); }
public Repository() { _context = new ToDoContext(); _dbSet = _context.Set <Task>(); }
public List <Tablo> GetirHepsi() { using var context = new ToDoContext(); return(context.Set <Tablo>().ToList()); }