public void Demonstrate_DbReferenceFetch() { var supplier = new Supplier { Name = "Acme" }; supplier.Save(); var product = new Product { Name = "Shovel", Price = "17.50", Sku = "a3k4j22je9", Weight = "11", Supplier = new DbReference<Supplier>(supplier.Id) }; product.Save(); var fetched = Product.GetById(product.Id); Assert.AreEqual(supplier.Id, fetched.GetRef(x => x.Supplier).Id); }
public void Demonstrate_ActiveRecordStyleAPI() { var product = new Product { Name = "DVD Player", Price = "89.95", Sku = "d9ejr3jj3e" }; product.Save(); var fetched = Product.GetById(product.Id); Assert.AreEqual(product.Sku, fetched.Sku); product.Delete(); var reFetched = Product.GetById(product.Id); Assert.IsNull(reFetched); }