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


C# EntityType.RemoveProperty方法代码示例

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


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

示例1: Members_check_arguments

        public void Members_check_arguments()
        {
            Assert.Equal(
                "type",
                // ReSharper disable once AssignNullToNotNullAttribute
                Assert.Throws<ArgumentNullException>(() => new EntityType((Type)null)).ParamName);

            Assert.Equal(
                "name",
                // ReSharper disable once AssignNullToNotNullAttribute
                Assert.Throws<ArgumentNullException>(() => new EntityType((string)null)).ParamName);

            var entityType = new EntityType(typeof(Random));

            Assert.Equal(
                "propertyInfo",
                // ReSharper disable once AssignNullToNotNullAttribute
                Assert.Throws<ArgumentNullException>(() => entityType.AddProperty((PropertyInfo)null)).ParamName);

            Assert.Equal(
                "property",
                // ReSharper disable once AssignNullToNotNullAttribute
                Assert.Throws<ArgumentNullException>(() => entityType.RemoveProperty(null)).ParamName);

            Assert.Equal(
                Strings.FormatArgumentIsEmpty("name"),
                Assert.Throws<ArgumentException>(() => entityType.TryGetProperty("")).Message);

            Assert.Equal(
                Strings.FormatArgumentIsEmpty("name"),
                Assert.Throws<ArgumentException>(() => entityType.GetProperty("")).Message);
        }
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:32,代码来源:EntityTypeTest.cs

示例2: Property_back_pointer_is_fixed_up_as_property_is_added_and_removed

        public void Property_back_pointer_is_fixed_up_as_property_is_added_and_removed()
        {
            var entityType1 = new EntityType(typeof(Customer));

            var property = entityType1.AddProperty(Customer.IdProperty);

            Assert.Same(entityType1, property.EntityType);

            entityType1.RemoveProperty(property);

            Assert.Empty(entityType1.Properties);
            Assert.Null(property.EntityType);
        }
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:13,代码来源:EntityTypeTest.cs

示例3: Can_add_and_remove_properties

        public void Can_add_and_remove_properties()
        {
            var entityType = new EntityType(typeof(Customer));

            var property1 = entityType.AddProperty(Customer.IdProperty);
            var property2 = entityType.AddProperty(Customer.NameProperty);

            Assert.True(new[] { property1, property2 }.SequenceEqual(entityType.Properties));

            entityType.RemoveProperty(property1);

            Assert.True(new[] { property2 }.SequenceEqual(entityType.Properties));
        }
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:13,代码来源:EntityTypeTest.cs

示例4: Cannot_remove_property_when_used_by_an_index

        public void Cannot_remove_property_when_used_by_an_index()
        {
            var entityType = new EntityType(typeof(Customer), new Model());
            var property = entityType.GetOrAddProperty(Customer.IdProperty);

            entityType.GetOrAddIndex(property);

            Assert.Equal(
                Strings.PropertyInUse("Id", typeof(Customer).FullName),
                Assert.Throws<InvalidOperationException>(() => entityType.RemoveProperty(property)).Message);
        }
开发者ID:thegido,项目名称:EntityFramework,代码行数:11,代码来源:EntityTypeTest.cs

示例5: Cannot_remove_property_when_used_by_foreign_key

        public void Cannot_remove_property_when_used_by_foreign_key()
        {
            var customerType = new EntityType(typeof(Customer), new Model());
            var customerPk = customerType.GetOrSetPrimaryKey(customerType.GetOrAddProperty(Customer.IdProperty));

            var orderType = new EntityType(typeof(Order), new Model());
            var customerFk = orderType.GetOrAddProperty(Order.CustomerIdProperty);
            orderType.GetOrAddForeignKey(customerFk, customerPk);

            Assert.Equal(
                Strings.PropertyInUse("CustomerId", typeof(Order).FullName),
                Assert.Throws<InvalidOperationException>(() => orderType.RemoveProperty(customerFk)).Message);
        }
开发者ID:thegido,项目名称:EntityFramework,代码行数:13,代码来源:EntityTypeTest.cs

示例6: Can_add_and_remove_properties

        public void Can_add_and_remove_properties()
        {
            var entityType = new EntityType(typeof(Customer), new Model());
            Assert.Null(entityType.RemoveProperty(new Property("Id", typeof(int), entityType)));

            var property1 = entityType.AddProperty("Id", typeof(int));

            Assert.False(property1.IsShadowProperty);
            Assert.Equal("Id", property1.Name);
            Assert.Same(typeof(int), property1.ClrType);
            Assert.False(((IProperty)property1).IsConcurrencyToken);
            Assert.Same(entityType, property1.EntityType);

            var property2 = entityType.AddProperty("Name", typeof(string));

            Assert.True(new[] { property1, property2 }.SequenceEqual(entityType.Properties));

            Assert.Same(property1, entityType.RemoveProperty(property1));
            Assert.Null(entityType.RemoveProperty(property1));

            Assert.True(new[] { property2 }.SequenceEqual(entityType.Properties));

            Assert.Same(property2, entityType.RemoveProperty(new Property("Name", typeof(string), entityType)));

            Assert.Empty(entityType.Properties);
        }
开发者ID:thegido,项目名称:EntityFramework,代码行数:26,代码来源:EntityTypeTest.cs

示例7: Can_set_and_reset_key

        public void Can_set_and_reset_key()
        {
            var entityType = new EntityType(typeof(Customer));

            var property1 = entityType.AddProperty(Customer.IdProperty);
            var property2 = entityType.AddProperty(Customer.NameProperty);

            entityType.SetKey(property1, property2);

            Assert.True(new[] { property1, property2 }.SequenceEqual(entityType.GetKey().Properties));
            Assert.True(new[] { property1, property2 }.SequenceEqual(entityType.Properties));

            entityType.RemoveProperty(property1);

            Assert.True(new[] { property2 }.SequenceEqual(entityType.GetKey().Properties));
            Assert.True(new[] { property2 }.SequenceEqual(entityType.Properties));

            property1 = entityType.AddProperty(Customer.IdProperty);

            entityType.SetKey(property1);

            Assert.True(new[] { property1 }.SequenceEqual(entityType.GetKey().Properties));
            Assert.True(new[] { property1, property2 }.SequenceEqual(entityType.Properties));
        }
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:24,代码来源:EntityTypeTest.cs


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