public void UsingObject_DeletesRows() { Person p1 = new Person { Active = "Y", FirstName = "Foo", LastName = "Bar", DateCreated = DateTime.UtcNow }; Person p2 = new Person { Active = "Y", FirstName = "Foo", LastName = "Bar", DateCreated = DateTime.UtcNow }; Person p3 = new Person { Active = "Y", FirstName = "Foo", LastName = "Barz", DateCreated = DateTime.UtcNow }; Db.Insert(p1); Db.Insert(p2); Db.Insert(p3); var list = Db.GetList <Person>(); Assert.AreEqual(3, list.Count()); var result = Db.Delete <Person>(new { LastName = "Bar" }); Assert.IsTrue(result); list = Db.GetList <Person>(); Assert.AreEqual(1, list.Count()); }
public void UsingPredicate_DeletesRows() { Person p1 = new Person { Active = "Y", FirstName = "Foo", LastName = "Bar", DateCreated = DateTime.UtcNow }; Person p2 = new Person { Active = "Y", FirstName = "Foo", LastName = "Bar", DateCreated = DateTime.UtcNow }; Person p3 = new Person { Active = "Y", FirstName = "Foo", LastName = "Barz", DateCreated = DateTime.UtcNow }; Db.Insert(p1); Db.Insert(p2); Db.Insert(p3); var list = Db.GetList <Person>(); Assert.AreEqual(3, list.Count()); IPredicate pred = Predicates.Field <Person>(p => p.LastName, Operator.Eq, "Bar"); var result = Db.Delete <Person>(pred); Assert.IsTrue(result); list = Db.GetList <Person>(); Assert.AreEqual(1, list.Count()); }
public void AddsEntityToDatabase_ReturnsKey() { Person p = new Person { Active = "Y", FirstName = "Foo", LastName = "Bar", DateCreated = DateTime.UtcNow }; var id = Db.Insert(p); Assert.AreEqual(1, id); Assert.AreEqual(1, p.Id); }
public void UsingKey_DeletesFromDatabase() { Person p1 = new Person { Active = "Y", FirstName = "Foo", LastName = "Bar", DateCreated = DateTime.UtcNow }; var id = Db.Insert(p1); Person p2 = Db.Get <Person>(id); Db.Delete(p2); Assert.IsNull(Db.Get <Person>(id)); }
public void UsingKey_ReturnsEntity() { Person p1 = new Person { Active = "Y", FirstName = "Foo", LastName = "Bar", DateCreated = DateTime.UtcNow }; var id = Db.Insert(p1); Person p2 = Db.Get <Person>(id); Assert.AreEqual(id, p2.Id); Assert.AreEqual("Foo", p2.FirstName); Assert.AreEqual("Bar", p2.LastName); }
public void UsingKey_UpdatesEntity() { Person p1 = new Person { Active = "Y", FirstName = "Foo", LastName = "Bar", DateCreated = DateTime.UtcNow }; var id = Db.Insert(p1); var p2 = Db.Get <Person>(id); p2.FirstName = "Baz"; p2.Active = "N"; Db.Update(p2); var p3 = Db.Get <Person>(id); Assert.AreEqual("Baz", p3.FirstName); Assert.AreEqual("Bar", p3.LastName); Assert.AreEqual("N", p3.Active); }
public void UsingKey_DeletesFromDatabase() { Person p1 = new Person { Active = "Y", FirstName = "Foo", LastName = "Bar", DateCreated = DateTime.UtcNow }; int id = Db.Insert(p1); Person p2 = Db.Get<Person>(id); Db.Delete(p2); Assert.IsNull(Db.Get<Person>(id)); }
public void UsingKey_UpdatesEntity() { Person p1 = new Person { Active = "Y", FirstName = "Foo", LastName = "Bar", DateCreated = DateTime.UtcNow }; int id = Db.Insert(p1); var p2 = Db.Get<Person>(id); p2.FirstName = "Baz"; p2.Active = "N"; Db.Update(p2); var p3 = Db.Get<Person>(id); Assert.AreEqual("Baz", p3.FirstName); Assert.AreEqual("Bar", p3.LastName); Assert.AreEqual("N", p3.Active); }
public void AddsEntityToDatabase_ReturnsKey() { Person p = new Person { Active = "Y", FirstName = "Foo", LastName = "Bar", DateCreated = DateTime.UtcNow }; int id = Db.Insert(p); Assert.AreEqual(1, id); Assert.AreEqual(1, p.Id); }
public void UsingKey_ReturnsEntity() { Person p1 = new Person { Active = "Y", FirstName = "Foo", LastName = "Bar", DateCreated = DateTime.UtcNow }; int id = Db.Insert(p1); Person p2 = Db.Get<Person>(id); Assert.AreEqual(id, p2.Id); Assert.AreEqual("Foo", p2.FirstName); Assert.AreEqual("Bar", p2.LastName); }
public void UsingPredicate_DeletesRows() { Person p1 = new Person { Active = "Y", FirstName = "Foo", LastName = "Bar", DateCreated = DateTime.UtcNow }; Person p2 = new Person { Active = "Y", FirstName = "Foo", LastName = "Bar", DateCreated = DateTime.UtcNow }; Person p3 = new Person { Active = "Y", FirstName = "Foo", LastName = "Barz", DateCreated = DateTime.UtcNow }; Db.Insert(p1); Db.Insert(p2); Db.Insert(p3); var list = Db.GetList<Person>(); Assert.AreEqual(3, list.Count()); IPredicate pred = Predicates.Field<Person>(p => p.LastName, Operator.Eq, "Bar"); var result = Db.Delete<Person>(pred); Assert.IsTrue(result); list = Db.GetList<Person>(); Assert.AreEqual(1, list.Count()); }
public void UsingObject_DeletesRows() { Person p1 = new Person { Active = "Y", FirstName = "Foo", LastName = "Bar", DateCreated = DateTime.UtcNow }; Person p2 = new Person { Active = "Y", FirstName = "Foo", LastName = "Bar", DateCreated = DateTime.UtcNow }; Person p3 = new Person { Active = "Y", FirstName = "Foo", LastName = "Barz", DateCreated = DateTime.UtcNow }; Db.Insert(p1); Db.Insert(p2); Db.Insert(p3); var list = Db.GetList<Person>(); Assert.AreEqual(3, list.Count()); var result = Db.Delete<Person>(new { LastName = "Bar" }); Assert.IsTrue(result); list = Db.GetList<Person>(); Assert.AreEqual(1, list.Count()); }