public void Delete(long id) { Profile entity = _accessor.Get <Profile>(x => x.Id == id); IEnumerable <ProfileGroupMapping> mappings = _accessor.GetList <ProfileGroupMapping>(x => x.IsActive && x.ProfileId == id); foreach (ProfileGroupMapping item in mappings) { _accessor.Delete(item); } _accessor.Delete(entity); }
public void Delete(long id) { Raspberry entity = _accessor.Get <Raspberry>(x => x.Id == id); IEnumerable <Valve> valves = _accessor.GetList <Valve>(x => x.IsActive && x.RaspberryId == id); if (valves != null) { foreach (Valve item in valves) { _accessor.Delete(item); } } _accessor.Delete(entity); }
public void Delete(long id) { Valve entity = _accessor.Get <Valve>(x => x.Id == id); IEnumerable <ValveGroupMapping> valveGroupMappings = _accessor.GetList <ValveGroupMapping>(x => x.IsActive && x.ValveId == id); if (valveGroupMappings != null) { foreach (ValveGroupMapping item in valveGroupMappings) { _accessor.Delete(item); } } _accessor.Delete(entity); }
public async Task DeleteSimpleEntity() { var mEntity = await DatabaseInitializeHelper.CreateSimpleMEntity(); using (IDataAccessor dataAccessor = new DataAccessor(_dbContextFactory)) { //Sicherstellen, dass die MEntity auch in der DB bekannt ist. Assert.IsTrue(await dataAccessor.Set<MEntity>().AnyAsync(mE => mE.Id.Equals(mEntity.Id))); } //Neuen DataAccessor holen, damit die Operation nicht durch LocalCache verfälscht wird using (IDataAccessor dataAccessor = new DataAccessor(_dbContextFactory)) { dataAccessor.Delete(mEntity); Assert.IsTrue(dataAccessor.HasPendingChanges, "HasPendingChanges should be true!"); await dataAccessor.SaveChangesAsync(); Assert.IsFalse(dataAccessor.HasPendingChanges, "HasPendingChanges should be false directly after Saving!"); } using (IDataAccessor dataAccessor = new DataAccessor(_dbContextFactory)) { //Sicherstellen, dass die MEntity auch in der DB bekannt ist. Assert.IsFalse(await dataAccessor.Set<MEntity>().AnyAsync(mE => mE.Id.Equals(mEntity.Id))); } }
public void Delete(long id) { Group entity = _accessor.Get <Group>(x => x.Id == id); IEnumerable <ValveGroupMapping> valveMappings = _accessor.GetList <ValveGroupMapping>(x => x.IsActive && x.GroupId == id); IEnumerable <ProfileGroupMapping> profileMappings = _accessor.GetList <ProfileGroupMapping>(x => x.IsActive && x.GroupId == id); foreach (ValveGroupMapping item in valveMappings) { _accessor.Delete(item); } foreach (ProfileGroupMapping item in profileMappings) { _accessor.Delete(item); } _accessor.Delete(entity); }
static void BasicUsage(DataAccessor dal) { Console.WriteLine("\nTest BasicUsage"); long newId = 2; // Add Console.WriteLine("Test Add"); Console.WriteLine("Org data:"); var list = dal.GetAll <Blog>().ToList(); PrintData(list); Blog newData = new Blog { BlogId = newId, Rating = 666, Url = "https://blog.test.com" }; dal.AddRecord(newData); dal.Save(); Console.WriteLine("New data:"); list = dal.GetAll <Blog>().ToList(); PrintData(list); Console.WriteLine(); // update Blog target = dal.GetByID <Blog>(newId); Console.WriteLine("Test Update"); target.Url = "https://newurl.test.com"; dal.Update(target); dal.Save(); list = dal.GetAll <Blog>().ToList(); PrintData(list); Console.WriteLine(); // delete Console.WriteLine("Test Delete"); dal.Delete(target); dal.Save(); list = dal.GetAll <Blog>().ToList(); PrintData(list); Console.WriteLine(); }
public async Task DeleteRelatedEntity() { var mEntity = await DatabaseInitializeHelper.CreateMEntityWithSomeNEntites(); var deletingNEntity = mEntity.NEntities.First(); using (IDataAccessor dataAccessor = new DataAccessor(_dbContextFactory)) { dataAccessor.Delete(deletingNEntity); Assert.IsTrue(dataAccessor.HasPendingChanges, "HasPendingChanges should be true!"); await dataAccessor.SaveChangesAsync(); Assert.IsFalse(dataAccessor.HasPendingChanges, "HasPendingChanges should be false directly after Saving!"); } using (IDataAccessor dataAccessor = new DataAccessor(_dbContextFactory)) { var reloadedMEntity = await dataAccessor.GetSingleAsync<MEntity>(mE => mE.Id.Equals(mEntity.Id), mE => mE.NEntities); Assert.AreEqual(1, reloadedMEntity.NEntities.Count); Assert.IsFalse(await dataAccessor.Set<MEntity>().AnyAsync(nE => nE.Id.Equals(deletingNEntity.Id))); } }
public async Task DeleteOtherEntity() { var nEntity = await DatabaseInitializeHelper.CreateNEntityWithSomeOtherEntities(); var deletingOtherEntity = nEntity.OtherEntities.First(); using (IDataAccessor dataAccessor = new DataAccessor(_dbContextFactory)) { dataAccessor.Delete(deletingOtherEntity); Assert.IsTrue(dataAccessor.HasPendingChanges, "HasPendingChanges should be true!"); await dataAccessor.SaveChangesAsync(); Assert.IsFalse(dataAccessor.HasPendingChanges, "HasPendingChanges should be false directly after Saving!"); } using (IDataAccessor dataAccessor = new DataAccessor(_dbContextFactory)) { var reloadedNEntity = await dataAccessor.GetSingleAsync<NEntity>(nE => nE.Id.Equals(nEntity.Id), nE => nE.OtherEntities); Assert.IsFalse(reloadedNEntity.OtherEntities.Any(oE => oE.Id.Equals(deletingOtherEntity.Id))); } }
public async Task CascadingDeleteNEntityWithOtherEntities() { var nEntity = await DatabaseInitializeHelper.CreateNEntityWithSomeOtherEntities(); using (IDataAccessor dataAccessor = new DataAccessor(_dbContextFactory)) { dataAccessor.Delete(nEntity); Assert.IsTrue(dataAccessor.HasPendingChanges, "HasPendingChanges should be true!"); await dataAccessor.SaveChangesAsync(); Assert.IsFalse(dataAccessor.HasPendingChanges, "HasPendingChanges should be false directly after Saving!"); } using (IDataAccessor dataAccessor = new DataAccessor(_dbContextFactory)) { Assert.IsFalse(await dataAccessor.Set<NEntity>().AnyAsync(nE => nE.Id.Equals(nEntity.Id))); } }
public void Delete(long id) { ProfileGroupMapping item = Get(id); _accessor.Delete(item); }
public void Delete <T>(T entity, int?commandTimeout = null) where T : class { _dataAccessor.Delete(entity); }
public void Delete(ConditionParametrizer conditions = null) { DataAccessor.Delete(this); }