当前位置: 首页>>代码示例>>C#>>正文


C# Seed.Id方法代码示例

本文整理汇总了C#中Seed.Id方法的典型用法代码示例。如果您正苦于以下问题:C# Seed.Id方法的具体用法?C# Seed.Id怎么用?C# Seed.Id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Seed的用法示例。


在下文中一共展示了Seed.Id方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: before_each

        void before_each()
        {
            seed = new Seed();

            books = new Books();

            seed.PurgeDb();

            seed.CreateTable("Books",
                seed.Id(),
                new { Title = "nvarchar(255)" }).ExecuteNonQuery();

            seed.CreateTable("Chapters",
                seed.Id(),
                new { BookId = "int" },
                new { Name = "nvarchar(255)" }).ExecuteNonQuery();

            book1Id = new { Title = "book 1" }.InsertInto("Books");

            new { BookId = book1Id, Name = "Chapter 1" }.InsertInto("Chapters");

            new { BookId = book1Id, Name = "Chapter 2" }.InsertInto("Chapters");

            book2Id = new { Title = "book 2" }.InsertInto("Books");

            new { BookId = book2Id, Name = "Chapter 1" }.InsertInto("Chapters");

            new { BookId = book2Id, Name = "Chapter 2" }.InsertInto("Chapters");
        }
开发者ID:bforrest,项目名称:Oak,代码行数:29,代码来源:eager_loading_for_has_many.cs

示例2: before_each

        void before_each()
        {
            seed = new Seed();

            seed.PurgeDb();

            bluePrints = new BluePrints();

            seed.CreateTable("Cars",
                seed.Id(),
                new { Model = "nvarchar(255)" }).ExecuteNonQuery();

            seed.CreateTable("BluePrints",
                seed.Id(),
                new { CarId = "int" },
                new { Sku = "nvarchar(255)" }).ExecuteNonQuery();

            car1Id = new { Model = "car 1" }.InsertInto("Cars");

            car2Id = new { Model = "car 2" }.InsertInto("Cars");

            bluePrint1Id = new { CarId = car1Id, Sku = "Sku 1" }.InsertInto("BluePrints");

            bluePrint2Id = new { CarId = car2Id, Sku = "Sku 2" }.InsertInto("BluePrints");
        }
开发者ID:bforrest,项目名称:Oak,代码行数:25,代码来源:eager_loading_for_belongs_to.cs

示例3: before_each

        void before_each()
        {
            seed = new Seed();

            markets = new Markets();

            seed.PurgeDb();

            seed.CreateTable("Markets",
                seed.Id(),
                new { Name = "nvarchar(255)" }).ExecuteNonQuery();

            seed.CreateTable("SupplyChains",
                seed.Id(),
                new { MarketId = "int" },
                new { SupplierId = "int" }).ExecuteNonQuery();

            seed.CreateTable("Suppliers",
                seed.Id(),
                new { Name = "nvarchar(255)" }).ExecuteNonQuery();

            supplier1Id = new { Name = "Supplier 1" }.InsertInto("Suppliers");

            supplier2Id = new { Name = "Supplier 2" }.InsertInto("Suppliers");

            market1Id = new { Name = "Market 1" }.InsertInto("Markets");

            market2Id = new { Name = "Market 2" }.InsertInto("Markets");

            new { MarketId = market1Id, SupplierId = supplier1Id }.InsertInto("SupplyChains");

            new { MarketId = market2Id, SupplierId = supplier1Id }.InsertInto("SupplyChains");
        }
开发者ID:bforrest,项目名称:Oak,代码行数:33,代码来源:eager_loading_for_has_many_through.cs

示例4: specify_db_can_be_specified

        void specify_db_can_be_specified()
        {
            var connectionString = ConfigurationManager.ConnectionStrings["AnotherDb"].ConnectionString;

            seed = new Seed(new ConnectionProfile
            {
                ConnectionString = connectionString
            });

            seed.PurgeDb();

            seed.CreateTable("Authors",
                seed.Id(),
                new { Name = "nvarchar(255)" }
            ).ExecuteNonQuery(seed.ConnectionProfile);

            seed.CreateTable("Emails",
                seed.Id(),
                new { AuthorId = "int" },
                new { Address = "nvarchar(255)" }
            ).ExecuteNonQuery(seed.ConnectionProfile);

            db = new DynamicDb(connectionString);

            var authorId = db.Authors().Insert(new { Name = "hello" });

            db.Emails().Insert(new { authorId, Address = "[email protected]" });

            (db.Authors().All().First().Email().Address as string).should_be("[email protected]");
        }
开发者ID:eugman,项目名称:Oak,代码行数:30,代码来源:core_behavior_dynamic_db.cs

示例5: describe_db_rows_to_json

        void describe_db_rows_to_json()
        {
            before = () =>
            {
                Seed seed = new Seed();

                seed.PurgeDb();

                seed.CreateTable("Rabbits", seed.Id(), new { Name = "nvarchar(255)" }).ExecuteNonQuery();

                seed.CreateTable("Tasks",
                    seed.Id(),
                    new { Description = "nvarchar(255)" },
                    new { RabbitId = "int" },
                    new { DueDate = "datetime" }).ExecuteNonQuery();

                var rabbitId = new { Name = "Yours Truly" }.InsertInto("Rabbits");

                new { rabbitId, Description = "bolt onto vans", DueDate = new DateTime(2013, 1, 14) }.InsertInto("Tasks");

                rabbitId = new { Name = "Hiro Protaganist" }.InsertInto("Rabbits");

                new { rabbitId, Description = "save the world", DueDate = new DateTime(2013, 1, 14) }.InsertInto("Tasks");

                new { rabbitId, Description = "deliver pizza", DueDate = new DateTime(2013, 1, 14) }.InsertInto("Tasks");

                rabbitId = new { Name = "Lots" }.InsertInto("Rabbits");

                for (int i = 0; i < 10; i++)
                {
                    new
                    {
                        rabbitId,
                        Description = "Task: " + i.ToString(),
                        DueDate = new DateTime(2013, 1, 14)
                    }.InsertInto("Tasks");
                }
            };

            it["disregards self referencing objects"] = () =>
            {
                var results = tasks.All().Include("Rabbits").ToList();

                (results as IEnumerable<dynamic>).ForEach(s =>
                {
                    s.Rabbit = s.Rabbit();
                });

                objectToConvert = new Gemini(new { Tasks = results });
                string expected = @"{ ""tasks"": [ { ""id"": 1, ""description"": ""bolt onto vans"", ""rabbitId"": 1, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 1, ""name"": ""Yours Truly"" } }, { ""id"": 2, ""description"": ""save the world"", ""rabbitId"": 2, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 2, ""name"": ""Hiro Protaganist"" } }, { ""id"": 3, ""description"": ""deliver pizza"", ""rabbitId"": 2, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 2, ""name"": ""Hiro Protaganist"" } }, { ""id"": 4, ""description"": ""Task: 0"", ""rabbitId"": 3, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 3, ""name"": ""Lots"" } }, { ""id"": 5, ""description"": ""Task: 1"", ""rabbitId"": 3, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 3, ""name"": ""Lots"" } }, { ""id"": 6, ""description"": ""Task: 2"", ""rabbitId"": 3, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 3, ""name"": ""Lots"" } }, { ""id"": 7, ""description"": ""Task: 3"", ""rabbitId"": 3, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 3, ""name"": ""Lots"" } }, { ""id"": 8, ""description"": ""Task: 4"", ""rabbitId"": 3, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 3, ""name"": ""Lots"" } }, { ""id"": 9, ""description"": ""Task: 5"", ""rabbitId"": 3, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 3, ""name"": ""Lots"" } }, { ""id"": 10, ""description"": ""Task: 6"", ""rabbitId"": 3, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 3, ""name"": ""Lots"" } }, { ""id"": 11, ""description"": ""Task: 7"", ""rabbitId"": 3, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 3, ""name"": ""Lots"" } }, { ""id"": 12, ""description"": ""Task: 8"", ""rabbitId"": 3, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 3, ""name"": ""Lots"" } }, { ""id"": 13, ""description"": ""Task: 9"", ""rabbitId"": 3, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 3, ""name"": ""Lots"" } } ] }";
                jsonString = DynamicToJson.Convert(objectToConvert);
                jsonString.should_be(expected);
            };
        }
开发者ID:amirrajan,项目名称:Oak,代码行数:54,代码来源:serialization_of_self_reference_objects.cs

示例6: GenerateNodeKeyTest

 public void GenerateNodeKeyTest()
 {
     var zeroBytes = new byte[16];
     var pair = new Seed(zeroBytes).SetNodeKey().KeyPair();
     Assert.AreEqual("n9LPxYzbDpWBZ1bC3J3Fdkgqoa3FEhVKCnS8yKp7RFQFwuvd8Q2c", 
                     pair.Id());
 }
开发者ID:sublimator,项目名称:ripple-dot-net,代码行数:7,代码来源:DerivationTests.cs

示例7: before_each

        void before_each()
        {
            seed = new Seed();

            seed.PurgeDb();

            agents = new Agents();

            seed.CreateTable("Booths",
                seed.Id(),
                new { BoothId = "int" },
                new { Name = "nvarchar(255)" }).ExecuteNonQuery();

            seed.CreateTable("Agents",
                new { Id = "int" },
                new { BoothId = "int" },
                new { Name = "nvarchar(255)" }).ExecuteNonQuery();

            new { BoothId = 500, Name = "Booth 500" }.InsertInto("Booths");

            new { BoothId = 500, Name = "Agent 1" }.InsertInto("Agents");
        }
开发者ID:eugman,项目名称:Oak,代码行数:22,代码来源:eager_loading_for_belongs_to_with_overridden_primary_key.cs

示例8: describe_db_rows_to_json

        void describe_db_rows_to_json()
        {
            before = () =>
            {
                Seed seed = new Seed();

                seed.PurgeDb();

                seed.CreateTable("Rabbits", seed.Id(), new { Name = "nvarchar(255)" }).ExecuteNonQuery();

                seed.CreateTable("Tasks", seed.Id(), new { Description = "nvarchar(255)" }, new { RabbitId = "int" }).ExecuteNonQuery();

                var rabbitId = new { Name = "YT" }.InsertInto("Rabbits");

                var taskId = new { Description = "bolt onto vans", rabbitId }.InsertInto("Tasks");

                new { Description = "save the world", rabbitId }.InsertInto("Tasks");
            };

            it["disregards self referencing objects"] = () =>
            {
                var results = tasks.All().Include("Rabbits").ToList();

                (results as IEnumerable<dynamic>).ForEach(s =>
                {
                    s.Rabbit = s.Rabbit();
                });

                dynamic newGemini = new Gemini(new { Tasks = results });

                string jsonString = DynamicToJson.Convert(newGemini);

                jsonString.should_be(@"{ ""Tasks"": [ { ""Id"": 1, ""Description"": ""bolt onto vans"", ""RabbitId"": 1, ""Rabbit"": { ""Id"": 1, ""Name"": ""YT"", ""Task"": [ { ""Id"": 2, ""Description"": ""save the world"", ""RabbitId"": 1 } ] } } ] }");
            };
        }
开发者ID:girish66,项目名称:Oak,代码行数:35,代码来源:describe_DynamicToJson.cs

示例9: describe_track_back_property

        void describe_track_back_property()
        {
            before = () =>
            {
                Seed seed = new Seed();

                seed.PurgeDb();

                seed.CreateTable("Rabbits", seed.Id(), new { Name = "nvarchar(255)" }).ExecuteNonQuery();

                seed.CreateTable("Tasks", seed.Id(), new { Description = "nvarchar(255)" }, new { RabbitId = "int" }).ExecuteNonQuery();

                rabbitId = new { Name = "YT" }.InsertInto("Rabbits");

                task1Id = new { Description = "task 1", rabbitId }.InsertInto("Tasks");

                task2Id = new { Description = "task 2", rabbitId }.InsertInto("Tasks");

                task3Id = new { Description = "task 3", rabbitId }.InsertInto("Tasks");
            };

            it["tracks back to multiple instances, converting a single value to a collection"] = () =>
            {
                var allTasks = tasks.All().Include("Rabbit") as DynamicModels;

                var task = allTasks.First();

                (task.Rabbit().Task as List<dynamic>).Count.should_be(3);

                (task.Rabbit().Task as List<dynamic>).should_contain(allTasks.First() as object);

                (task.Rabbit().Task as List<dynamic>).should_contain(allTasks.Second() as object);

                (task.Rabbit().Task as List<dynamic>).should_contain(allTasks.Last() as object);
            };
        }
开发者ID:eugman,项目名称:Oak,代码行数:36,代码来源:eager_loading_for_belongs_to_with_duplicates.cs


注:本文中的Seed.Id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。