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


C# EntityType.ShadowPropertyCount方法代码示例

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


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

示例1: Indexes_are_rebuilt_when_more_properties_added_or_relevant_state_changes

        public void Indexes_are_rebuilt_when_more_properties_added_or_relevant_state_changes()
        {
            var entityType = new EntityType(typeof(FullNotificationEntity), new Model());

            var nameProperty = entityType.GetOrAddProperty("Name", typeof(string));
            entityType.GetOrAddProperty("Id", typeof(int), shadowProperty: true).IsConcurrencyToken = true;

            Assert.Equal(0, entityType.GetProperty("Id").Index);
            Assert.Equal(1, entityType.GetProperty("Name").Index);

            Assert.Equal(0, entityType.GetProperty("Id").GetShadowIndex());
            Assert.Equal(-1, entityType.GetProperty("Name").GetShadowIndex());

            Assert.Equal(0, entityType.GetProperty("Id").GetOriginalValueIndex());
            Assert.Equal(-1, entityType.GetProperty("Name").GetOriginalValueIndex());

            Assert.Equal(1, entityType.ShadowPropertyCount());
            Assert.Equal(1, entityType.OriginalValueCount());

            var gameProperty = entityType.GetOrAddProperty("Game", typeof(int), shadowProperty: true);
            gameProperty.IsConcurrencyToken = true;

            var maneProperty = entityType.GetOrAddProperty("Mane", typeof(int), shadowProperty: true);
            maneProperty.IsConcurrencyToken = true;

            Assert.Equal(0, entityType.GetProperty("Game").Index);
            Assert.Equal(1, entityType.GetProperty("Id").Index);
            Assert.Equal(2, entityType.GetProperty("Mane").Index);
            Assert.Equal(3, entityType.GetProperty("Name").Index);

            Assert.Equal(0, entityType.GetProperty("Game").GetShadowIndex());
            Assert.Equal(1, entityType.GetProperty("Id").GetShadowIndex());
            Assert.Equal(2, entityType.GetProperty("Mane").GetShadowIndex());
            Assert.Equal(-1, entityType.GetProperty("Name").GetShadowIndex());

            Assert.Equal(0, entityType.GetProperty("Game").GetOriginalValueIndex());
            Assert.Equal(1, entityType.GetProperty("Id").GetOriginalValueIndex());
            Assert.Equal(2, entityType.GetProperty("Mane").GetOriginalValueIndex());
            Assert.Equal(-1, entityType.GetProperty("Name").GetOriginalValueIndex());

            Assert.Equal(3, entityType.ShadowPropertyCount());
            Assert.Equal(3, entityType.OriginalValueCount());

            gameProperty.IsConcurrencyToken = false;
            nameProperty.IsConcurrencyToken = true;

            Assert.Equal(0, entityType.GetProperty("Game").Index);
            Assert.Equal(1, entityType.GetProperty("Id").Index);
            Assert.Equal(2, entityType.GetProperty("Mane").Index);
            Assert.Equal(3, entityType.GetProperty("Name").Index);

            Assert.Equal(0, entityType.GetProperty("Game").GetShadowIndex());
            Assert.Equal(1, entityType.GetProperty("Id").GetShadowIndex());
            Assert.Equal(2, entityType.GetProperty("Mane").GetShadowIndex());
            Assert.Equal(-1, entityType.GetProperty("Name").GetShadowIndex());

            Assert.Equal(-1, entityType.GetProperty("Game").GetOriginalValueIndex());
            Assert.Equal(0, entityType.GetProperty("Id").GetOriginalValueIndex());
            Assert.Equal(1, entityType.GetProperty("Mane").GetOriginalValueIndex());
            Assert.Equal(2, entityType.GetProperty("Name").GetOriginalValueIndex());

            Assert.Equal(3, entityType.ShadowPropertyCount());
            Assert.Equal(3, entityType.OriginalValueCount());

            gameProperty.IsShadowProperty = false;
            nameProperty.IsShadowProperty = true;

            Assert.Equal(0, entityType.GetProperty("Game").Index);
            Assert.Equal(1, entityType.GetProperty("Id").Index);
            Assert.Equal(2, entityType.GetProperty("Mane").Index);
            Assert.Equal(3, entityType.GetProperty("Name").Index);

            Assert.Equal(-1, entityType.GetProperty("Game").GetShadowIndex());
            Assert.Equal(0, entityType.GetProperty("Id").GetShadowIndex());
            Assert.Equal(1, entityType.GetProperty("Mane").GetShadowIndex());
            Assert.Equal(2, entityType.GetProperty("Name").GetShadowIndex());

            Assert.Equal(-1, entityType.GetProperty("Game").GetOriginalValueIndex());
            Assert.Equal(0, entityType.GetProperty("Id").GetOriginalValueIndex());
            Assert.Equal(1, entityType.GetProperty("Mane").GetOriginalValueIndex());
            Assert.Equal(2, entityType.GetProperty("Name").GetOriginalValueIndex());

            Assert.Equal(3, entityType.ShadowPropertyCount());
            Assert.Equal(3, entityType.OriginalValueCount());
        }
开发者ID:thegido,项目名称:EntityFramework,代码行数:85,代码来源:EntityTypeTest.cs

示例2: Can_get_property_indexes

        public void Can_get_property_indexes()
        {
            var entityType = new EntityType(typeof(Customer), new Model());

            entityType.GetOrAddProperty(Customer.NameProperty);
            entityType.GetOrAddProperty("Id", typeof(int), shadowProperty: true);
            entityType.GetOrAddProperty("Mane", typeof(int), shadowProperty: true);

            Assert.Equal(0, entityType.GetProperty("Id").Index);
            Assert.Equal(1, entityType.GetProperty("Mane").Index);
            Assert.Equal(2, entityType.GetProperty("Name").Index);

            Assert.Equal(0, entityType.GetProperty("Id").GetShadowIndex());
            Assert.Equal(1, entityType.GetProperty("Mane").GetShadowIndex());
            Assert.Equal(-1, entityType.GetProperty("Name").GetShadowIndex());

            Assert.Equal(2, entityType.ShadowPropertyCount());
        }
开发者ID:thegido,项目名称:EntityFramework,代码行数:18,代码来源:EntityTypeTest.cs


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