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


C# BindingContext.UnregisterColumnBinding方法代码示例

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


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

示例1: PersistAndFind

        public void PersistAndFind()
        {
            var bindingContext = new BindingContext();
            Assert.IsFalse(bindingContext.StrictExplicitColumnBinding);
            Assert.IsFalse(bindingContext.StrictExplicitKeyBinding);
            Assert.IsFalse(bindingContext.StrictExplicitTableBinding);

            bindingContext.StrictExplicitColumnBinding = true;

            Assert.IsTrue(bindingContext.RegisterColumnBinding(typeof(EntityA), new ColumnBindingEntityA()));
            Assert.IsFalse(bindingContext.RegisterColumnBinding(typeof(EntityA), new ColumnBindingEntityA()));
            Assert.IsTrue(bindingContext.RegisterColumnBinding(typeof(EntityB), new ColumnBinding("b", "qb")));
            Assert.IsTrue(bindingContext.RegisterColumnBinding(typeof(EntityC1), new ColumnBinding("c", "1")));
            Assert.IsTrue(bindingContext.RegisterColumnBinding(typeof(EntityC2), new ColumnBinding("c", "2")));

            var eb1 = new EntityB();
            TestBase.TestSerialization(eb1);

            var eb2 = new EntityB { A = new EntityA() };
            TestBase.TestSerialization(eb2);

            var ec1 = new EntityC1 { A = new EntityA() };
            TestBase.TestSerialization(ec1);

            var ec2 = new EntityC2 { A = new EntityA() };
            TestBase.TestSerialization(ec2);

            using (var em = Emf.CreateEntityManager(bindingContext))
            {
                Assert.IsTrue(em.IsTypeDeclared<EntityA>());
                Assert.IsTrue(em.IsTypeDeclared<EntityB>());
                Assert.IsTrue(em.IsTypeDeclared<EntityC1>());
                Assert.IsTrue(em.IsTypeDeclared<EntityC2>());

                em.Configuration.Binding.StrictExplicitColumnBinding = true;

                em.Persist(eb1);
                Assert.IsNotNull(eb1.Key);
                Assert.IsFalse(string.IsNullOrEmpty(eb1.Key.Row));
                Assert.AreEqual("b", eb1.Key.ColumnFamily);
                Assert.AreEqual("qb", eb1.Key.ColumnQualifier);

                em.Persist(eb2);
                Assert.IsNotNull(eb2.Key);
                Assert.IsFalse(string.IsNullOrEmpty(eb2.Key.Row));
                Assert.AreEqual("b", eb2.Key.ColumnFamily);
                Assert.AreEqual("qb", eb2.Key.ColumnQualifier);

                Assert.IsNotNull(eb2.A.Key);
                Assert.IsFalse(string.IsNullOrEmpty(eb2.A.Key.Row));
                Assert.AreEqual("a", eb2.A.Key.ColumnFamily);
                Assert.AreEqual("qa", eb2.A.Key.ColumnQualifier);

                em.Persist(ec1);
                Assert.IsNotNull(ec1.Key);
                Assert.IsFalse(string.IsNullOrEmpty(ec1.Key.Row));
                Assert.AreEqual("c", ec1.Key.ColumnFamily);
                Assert.AreEqual("1", ec1.Key.ColumnQualifier);

                em.Persist(ec2);
                Assert.IsNotNull(ec2.Key);
                Assert.IsFalse(string.IsNullOrEmpty(ec2.Key.Row));
                Assert.AreEqual("c", ec2.Key.ColumnFamily);
                Assert.AreEqual("2", ec2.Key.ColumnQualifier);
            }

            using (var em = Emf.CreateEntityManager(bindingContext))
            {
                var _eb1 = em.Find<EntityB>(eb1.Key);
                Assert.AreEqual(eb1, _eb1);

                var _ea2 = em.Find<EntityA>(eb2.A.Key);
                Assert.AreEqual(eb2.A, _ea2);

                var _eb2 = em.Find<EntityB>(eb2.Key);
                Assert.AreEqual(eb2, _eb2);

                var _ec1 = em.Find<EntityC1>(ec1.Key);
                Assert.AreEqual(ec1, _ec1);

                var _ec2 = em.Find<EntityC2>(ec2.Key);
                Assert.AreEqual(ec2, _ec2);

                var ecl = em.Fetch<EntityC>().ToList();
                Assert.AreEqual(2, ecl.Count);
                Assert.IsTrue(ecl.Contains(_ec1));
                Assert.IsTrue(ecl.Contains(_ec2));
            }

            Assert.IsTrue(bindingContext.UnregisterColumnBinding(typeof(EntityA)));
            Assert.IsFalse(bindingContext.UnregisterColumnBinding(typeof(EntityA)));
            Assert.IsTrue(bindingContext.UnregisterColumnBinding(typeof(EntityB)));
            Assert.IsTrue(bindingContext.UnregisterColumnBinding(typeof(EntityC1)));
            Assert.IsTrue(bindingContext.UnregisterColumnBinding(typeof(EntityC2)));
        }
开发者ID:andysoftdev,项目名称:ht4o,代码行数:95,代码来源:TestColumnBinding.cs


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