Example #1
0
            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
            }
Example #2
0
        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);
            }
        }
Example #3
0
            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
            }
Example #4
0
        // ----- Relations ----------------------------------------------------

        internal string GetFkName(string kind)
        {
            return($"{kind}_{Api.DefaultKey()}");
        }
Example #5
0
 public SlxStyleKeyProvider(BeanApi api, string defaultKey = "")
 {
     _defaultKey = defaultKey == string.Empty ? api.DefaultKey() : defaultKey;
     api?.ReplaceAutoIncrement(_defaultKey);
 }
Example #6
0
            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
            }
Example #7
0
            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
            }