Below are some code samples using the Slipjig framework.
Here's some code to create and save a simple entity tree:
Vendor v = new Vendor();
v.VendorName = "Oracle";
Product p = new Product();
p.Vendor = v;
p.ProductSKU = "ORDB10G";
p.ProductName = "Oracle 10g";
v.Products.Add(p);
p = new Product();
p.Vendor = v;
p.ProductSKU = "ORSVC10";
p.ProductName = "Oracle Services For Java 10";
v.Products.Add(p);
v.Persist();
Here's an example showing how to load all instances of a given entity, using a static entity method:
List<Customer> custs = Customer.LoadAll();
Two more examples showing ways to load entities using a template (query-by-example):
Product pt = new Product();
pt.ProductSKU = "VS2005PRO";
List<Product> list1 = Product.LoadByTemplate(pt);
Vendor vt = new Vendor();
vt.VendorName = "Microsoft";
TemplateLoader<Vendor> ldr = new TemplateLoader<Vendor>(vt);
List<Vendor> list2 = ldr.Load();
Loading one or many entities by key:
Order o = Order.LoadByKey("123");
List<Order> orders = Order.LoadByKey(new string[] { "123", "456" });
Slipjig can set up a data command to call any arbitrary stored procedure. It also provides a method to set all the parameter values in one shot. This is more of an ad-hoc convenience thing than anything else; in particular, SetParamValues() is not type-safe and wouldn't be part of everyday usage. Here's a sample calling a stored proc that takes an instance of every data type:
using (IDbSql db = (IDbSql)DbFactory.GetDB("Test")) {
IDbCommand cmd = db.GetStoredProcCommand("usp_test");
db.SetParamValues(cmd, 1, 1, 1, 1, "a", "a", "a", "a", "a", "a", "a", "2006-02-24", "2006-02-24", 0, new byte[] {}, new byte[] {}, new byte[] {}, new byte[] {}, 0m, 0m, 0, 0, 0, Guid.NewGuid(), 0);
int recs = db.ExecuteNonQuery(cmd);
}