void Snippet1(BeanApi api) { #if CODE api.DefaultKey(false); // turn off auto-increment keys api.AddObserver(new GuidKeyObserver()); // but beware of http://www.informit.com/articles/printerfriendly/25862 #endif }
public void Scenario() { using (var api = new BeanApi("data source=:memory:", SQLiteFactory.Instance)) { api.EnterFluidMode(); api.DefaultKey(false); api.AddObserver(new GuidKeyObserver()); var bean = api.Dispense("foo"); var key = api.Store(bean); Console.WriteLine("Key is: " + key); } }
void Samples(BeanApi api) { #if CODE // Custom key name for beans of kind "book" api.Key("book", "book_id"); // Custom key name for custom bean class Book (see Custom Bean Classes) api.Key <Book>("book_id"); // Custom non-autoincrement key api.Key("book", "book_id", false); // Compound key (order_id, product_id) for beans of kind "order_item" api.Key("order_item", "order_id", "product_id"); // Change defaults for all beans api.DefaultKey("Oid", false); #endif }
// ----- Relations ---------------------------------------------------- internal string GetFkName(string kind) { return($"{kind}_{Api.DefaultKey()}"); }
public SlxStyleKeyProvider(BeanApi api, string defaultKey = "") { _defaultKey = defaultKey == string.Empty ? api.DefaultKey() : defaultKey; api?.ReplaceAutoIncrement(_defaultKey); }
void Samples(BeanApi api) { #if CODE // Custom key name for beans of kind "book" api.Key("book", "book_id"); // Custom key name for custom bean class Book (see Custom Bean Classes) api.Key<Book>("book_id"); // Custom non-autoincrement key api.Key("book", "book_id", false); // Compound key (order_id, product_id) for beans of kind "order_item" api.Key("order_item", "order_id", "product_id"); // Change defaults for all beans api.DefaultKey("Oid", false); #endif }