public void DeleteTest() { using (Db4oDatabase db = new Db4oDatabase(dbfile1, container)) { MockObject obj1 = new MockObject { Name = "Jacky", Phone = "22305779", Address = new Address { Office = "ZDH", Home = "BBG" } }; db.Store(obj1); Assert.AreEqual(1, db.Load <MockObject>(delegate(MockObject obj) { return(obj.Name == "Jacky"); }).Count); MockObject obj2 = db.Load <MockObject>(delegate(MockObject obj) { return(obj.Name == "Jacky"); })[0]; db.Delete(obj2); Assert.AreEqual(0, db.Load <MockObject>(delegate(MockObject obj) { return(obj.Name == "Jacky"); }).Count); } }
public void DeleteTest() { using (Db4oDatabase db = new Db4oDatabase(dbfile1, container)) { MockObject obj1 = new MockObject { Name = "Jacky", Phone = "22305779", Address = new Address { Office = "ZDH", Home = "BBG" } }; db.Store(obj1); Assert.AreEqual(1, db.Load<MockObject>(delegate(MockObject obj) { return obj.Name == "Jacky"; }).Count); MockObject obj2 = db.Load<MockObject>(delegate(MockObject obj) { return obj.Name == "Jacky"; })[0]; db.Delete(obj2); Assert.AreEqual(0, db.Load<MockObject>(delegate(MockObject obj) { return obj.Name == "Jacky"; }).Count); } }
public override bool DeleteUser(string username, bool deleteAllRelatedData) { using (Db4oDatabase dbc = new Db4oDatabase(connectionString)) { var results = dbc.Query <User>(u => u.Username == username && u.ApplicationName == applicationName); if (results.Count != 1) { return(false); } User found = results[0]; dbc.Delete(found); } return(false); }
public override bool DeleteRole(string rolename, bool throwOnPopulatedRole) { if (!RoleExists(rolename)) { throw new ProviderException("Role does not exist."); } if (throwOnPopulatedRole && GetUsersInRole(rolename).Length > 0) { throw new ProviderException("Cannot delete a populated role."); } using (Db4oDatabase dbc = new Db4oDatabase(connectionString)) { IList <Role> results = dbc.Query((Role r) => r.Rolename == rolename && r.ApplicationName == applicationName); Role found = results[0]; dbc.Delete(found); return(true); } }
public override bool DeleteRole(string rolename, bool throwOnPopulatedRole) { if (!RoleExists(rolename)) throw new ProviderException("Role does not exist."); if (throwOnPopulatedRole && GetUsersInRole(rolename).Length > 0) throw new ProviderException("Cannot delete a populated role."); using (Db4oDatabase dbc = new Db4oDatabase(connectionString)) { IList<Role> results = dbc.Query((Role r) => r.Rolename == rolename && r.ApplicationName == applicationName); Role found = results[0]; dbc.Delete(found); return true; } }
public override bool DeleteUser(string username, bool deleteAllRelatedData) { using (Db4oDatabase dbc = new Db4oDatabase(connectionString)) { var results = dbc.Query<User>(u => u.Username == username && u.ApplicationName == applicationName); if (results.Count != 1) return false; User found = results[0]; dbc.Delete(found); } return false; }