本文整理汇总了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);
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}