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


C# InMemoryAdapter.SetAutoIncrementColumn方法代码示例

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


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

示例1: AutoIncrementShouldReturnNextIdInSequenceWhenOneRowExsists

        public void AutoIncrementShouldReturnNextIdInSequenceWhenOneRowExsists()
        {
            // Arrange
            var adapter = new InMemoryAdapter();
            adapter.SetAutoIncrementColumn("Users", "Id");

            Database.UseMockAdapter(adapter);
            var db = Database.Open();
            db.Users.Insert(Name: "Marcus");

            // Act
            var newId = db.Users.Insert(Name: "Per").Id;

            // Assert
            Assert.AreEqual(2, newId);
        }
开发者ID:da9l,项目名称:Simple.Data,代码行数:16,代码来源:InMemoryTests.cs

示例2: LeftJoinTest

        public void LeftJoinTest()
        {
            var adapter = new InMemoryAdapter();
            adapter.SetKeyColumn("Events", "Id");
            adapter.SetAutoIncrementColumn("Events", "Id");
            adapter.SetKeyColumn("Doors", "Id");
            adapter.SetAutoIncrementColumn("Doors", "Id");
            adapter.Join.Master("Events", "Id").Detail("Doors", "EventId");
            Database.UseMockAdapter(adapter);
            var db = Database.Open();
            db.Events.Insert(Id: 1, Code: "CodeMash2013", Name: "CodeMash 2013");
            db.Events.Insert(Id: 2, Code: "SomewhereElse", Name: "Some Other Conf");
            db.Doors.Insert(Id: 1, Code: "F7E08AC9-5E75-417D-A7AA-60E88B5B99AD", EventID: 1);
            db.Doors.Insert(Id: 2, Code: "0631C802-2748-4C63-A6D9-CE8C803002EB", EventID: 1);
            db.Doors.Insert(Id: 3, Code: "281ED88F-677D-49B9-84FA-4FAE022BBC73", EventID: 1);
            db.Doors.Insert(Id: 4, Code: "9DF7E964-1ECE-42E3-8211-1F2BF7054A0D", EventID: 2);
            db.Doors.Insert(Id: 5, Code: "9418123D-312A-4E8C-8807-59F0A63F43B9", EventID: 2);

            List<dynamic> actual = db.Doors.FindAll(db.Doors.Events.Code == "CodeMash2013")
                           .Select(db.Doors.Id, db.Events.Name)
                           .ToList();

            Assert.AreEqual(3, actual.Count);
        }
开发者ID:da9l,项目名称:Simple.Data,代码行数:24,代码来源:InMemoryTests.cs

示例3: AutoIncrementShouldSet1ForAutoIncrementedColumnsWhenNoRowsInTable

        public void AutoIncrementShouldSet1ForAutoIncrementedColumnsWhenNoRowsInTable()
        {
            // Arrange
            var adapter = new InMemoryAdapter();
            adapter.SetAutoIncrementColumn("Users", "Id");

            Database.UseMockAdapter(adapter);
            var db = Database.Open();

            // Act
            var newId = db.Users.Insert(Name: "Marcus").Id;

            // Assert
            Assert.AreEqual(1, newId);
        }
开发者ID:da9l,项目名称:Simple.Data,代码行数:15,代码来源:InMemoryTests.cs


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