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


C# InMemoryAdapter.SetKeyColumn方法代码示例

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


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

示例1: InsertAndGetShouldWork

 public void InsertAndGetShouldWork()
 {
     var adapter = new InMemoryAdapter();
     adapter.SetKeyColumn("Test", "Id");
     Database.UseMockAdapter(adapter);
     var db = Database.Open();
     db.Test.Insert(Id: 1, Name: "Alice");
     var record = db.Test.Get(1);
     Assert.IsNotNull(record);
     Assert.AreEqual(1, record.Id);
     Assert.AreEqual("Alice", record.Name);
 }
开发者ID:da9l,项目名称:Simple.Data,代码行数:12,代码来源:InMemoryTests.cs

示例2: InsertAndGetWithArrayPropertyShouldWork

 public void InsertAndGetWithArrayPropertyShouldWork()
 {
     var adapter = new InMemoryAdapter();
     adapter.SetKeyColumn("Test", "Id");
     Database.UseMockAdapter(adapter);
     var db = Database.Open();
     db.Test.Insert(Id: 1, Names: new List<string> {"Alice", "Bob", "Charlie"});
     People record = db.Test.Get(1);
     Assert.IsNotNull(record);
     Assert.AreEqual(1, record.Id);
     Assert.AreEqual("Alice", record.Names[0]);
     Assert.AreEqual("Bob", record.Names[1]);
     Assert.AreEqual("Charlie", record.Names[2]);
 }
开发者ID:JorgeGamba,项目名称:Simple.Data,代码行数:14,代码来源:CanAssignArray.cs

示例3: 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

示例4: UpsertShouldUpdateExistingRecord

 public void UpsertShouldUpdateExistingRecord()
 {
     var adapater = new InMemoryAdapter();
     adapater.SetKeyColumn("Test","Id");
     Database.UseMockAdapter(adapater);
     var db = Database.Open();
     db.Test.Upsert(Id: 1, SomeValue: "Testing");
     db.Test.Upsert(Id: 1, SomeValue: "Updated");
     List<dynamic> allRecords = db.Test.All().ToList();
     Assert.IsNotNull(allRecords);
     Assert.AreEqual(1,allRecords.Count);
     Assert.AreEqual("Updated", allRecords.Single().SomeValue);
 }
开发者ID:da9l,项目名称:Simple.Data,代码行数:13,代码来源:InMemoryTests.cs

示例5: UpsertShouldAddNewRecord

 public void UpsertShouldAddNewRecord()
 {
     var adapter = new InMemoryAdapter();
     adapter.SetKeyColumn("Test", "Id");
     Database.UseMockAdapter(adapter);
     var db = Database.Open();
     db.Test.Upsert(Id: 1, SomeValue: "Testing");
     var record = db.Test.Get(1);
     Assert.IsNotNull(record);
     Assert.AreEqual("Testing", record.SomeValue);
 }
开发者ID:da9l,项目名称:Simple.Data,代码行数:11,代码来源:InMemoryTests.cs

示例6: InsertAndGetWithTransactionShouldWork

 public void InsertAndGetWithTransactionShouldWork()
 {
     var adapter = new InMemoryAdapter();
     adapter.SetKeyColumn("Test", "Id");
     Database.UseMockAdapter(adapter);
     var db = Database.Open();
     using (var tx = db.BeginTransaction())
     {
         tx.Test.Insert(Id: 1, Name: "Alice");
         var record = tx.Test.Get(1);
         Assert.IsNotNull(record);
         Assert.AreEqual(1, record.Id);
         Assert.AreEqual("Alice", record.Name);
     }
 }
开发者ID:da9l,项目名称:Simple.Data,代码行数:15,代码来源:InMemoryTests.cs

示例7: TestUpdate

 public void TestUpdate()
 {
     var adapter = new InMemoryAdapter();
     adapter.SetKeyColumn("Test", "Id");
     Database.UseMockAdapter(adapter);
     var db = Database.Open();
     var alice = db.Test.Insert(Id: 1, Name: "Alice");
     var allyce = new { Id = 1, Name = "Allyce" };
     int updated = db.Test.Update(allyce);
     Assert.AreEqual(1, updated);
     var record = db.Test.FindById(1);
     Assert.AreEqual("Allyce", record.Name);
 }
开发者ID:da9l,项目名称:Simple.Data,代码行数:13,代码来源:InMemoryTests.cs

示例8: UpdateWithOriginalValuesRowsUpdatedShouldBeZeroIfNewValueAreSameAsOriginalValue

        public void UpdateWithOriginalValuesRowsUpdatedShouldBeZeroIfNewValueAreSameAsOriginalValue()
        {
            var adapter = new InMemoryAdapter();
            adapter.SetKeyColumn("Test", "Id");
            Database.UseMockAdapter(adapter);
            var db = Database.Open();
            db.Test.Upsert(Id: 1, SomeValue: "Testing");
            var record = db.Test.Get(1);
            var record1 = record.Clone();

            var rowsUpdated = db.Test.Update(record, record1);

            Assert.AreEqual(0, rowsUpdated);
        }
开发者ID:vertiman,项目名称:Simple.Data,代码行数:14,代码来源:InMemoryTests.cs

示例9: TestFindAcrossJoinAfterDelete

        public void TestFindAcrossJoinAfterDelete()
        {
            var adapter = new InMemoryAdapter();
            adapter.SetKeyColumn("Thing1Table", "Id");
            adapter.SetKeyColumn("Thing2Table", "Id");
            adapter.Join.Master("Thing1Table", "Id").Detail("ThingJoin", "Thing1Id");
            adapter.Join.Master("Thing2Table", "Id").Detail("ThingJoin", "Thing2Id");

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

            var thing1 = new {Id = 1, Name = "Thing1"};
            var thing2 = new {Id = 2, Name = "Thing2"};
            var thingJoin = new {Thing1Id = 1, Thing2Id = 2};
 
            db.Thing1Table.Insert(thing1);
            db.Thing2Table.Insert(thing2);
            db.ThingJoin.Insert(thingJoin);
 
            //Delete the join object.
            db.ThingJoin.DeleteAll(db.ThingJoin.Thing1Id == 1 && db.ThingJoin.Thing2Id == 2);
            
            //Ensure after we drop one of the relationships, there is only no records left in the join table.
            Assert.AreEqual(0, db.ThingJoin.All().ToList().Count);

            //Ensure we don't find the Thing across the join after the delete
            var foundByJoin = db.Thing1Table.FindAll(db.Thing1Table.ThingJoin.Thing1Id == 1).FirstOrDefault();
            Assert.IsNull(foundByJoin);
        }
开发者ID:vertiman,项目名称:Simple.Data,代码行数:29,代码来源:InMemoryTests.cs

示例10: ShouldBeAbleToSetAutoIncrementWhenSettingKeyColumn

        public void ShouldBeAbleToSetAutoIncrementWhenSettingKeyColumn()
        {
            // Arrange
            var adapter = new InMemoryAdapter();

            // Act
            adapter.SetKeyColumn("Users", "Id", true);

            // Assert
            Database.UseMockAdapter(adapter);
            var db = Database.Open();
            var firstId = db.Users.Insert(Name: "Marcus").Id;
            Assert.AreEqual(1, firstId);
        }
开发者ID:marcusoftnet,项目名称:Simple.Data,代码行数:14,代码来源:InMemoryTests.cs


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