本文整理汇总了C#中System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.Configure方法的典型用法代码示例。如果您正苦于以下问题:C# EntityTypeConfiguration.Configure方法的具体用法?C# EntityTypeConfiguration.Configure怎么用?C# EntityTypeConfiguration.Configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration
的用法示例。
在下文中一共展示了EntityTypeConfiguration.Configure方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configure_should_configure_modification_functions
public void Configure_should_configure_modification_functions()
{
var model = new EdmModel(DataSpace.CSpace);
var entityType = model.AddEntityType("E");
entityType.GetMetadataProperties().SetClrType(typeof(object));
model.AddEntitySet("ESet", entityType);
var modificationFunctionsConfigurationMock = new Mock<ModificationStoredProceduresConfiguration>();
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
entityTypeConfiguration.MapToStoredProcedures(modificationFunctionsConfigurationMock.Object, true);
entityType.SetConfiguration(entityTypeConfiguration);
var databaseMapping
= new DatabaseMappingGenerator(ProviderRegistry.Sql2008_ProviderInfo, ProviderRegistry.Sql2008_ProviderManifest).Generate(model);
entityTypeConfiguration.Configure(entityType, databaseMapping, ProviderRegistry.Sql2008_ProviderManifest);
modificationFunctionsConfigurationMock
.Verify(
m => m.Configure(
It.IsAny<EntityTypeModificationFunctionMapping>(), It.IsAny<DbProviderManifest>()),
Times.Once());
}
示例2: Configure_should_set_configuration
public void Configure_should_set_configuration()
{
var entityType = new EntityType("E", "N", DataSpace.CSpace);
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
entityTypeConfiguration.Configure(entityType, new EdmModel(DataSpace.CSpace));
Assert.Same(entityTypeConfiguration, entityType.GetConfiguration());
}
示例3: Configure_should_configure_entity_set_name
public void Configure_should_configure_entity_set_name()
{
var model = new EdmModel(DataSpace.CSpace);
var entityType = new EntityType("E", "N", DataSpace.CSpace);
var entitySet = model.AddEntitySet("ESet", entityType);
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object))
{
EntitySetName = "MySet"
};
entityTypeConfiguration.Configure(entityType, model);
Assert.Equal("MySet", entitySet.Name);
Assert.Same(entityTypeConfiguration, entitySet.GetConfiguration());
}
示例4: Configure_should_throw_when_key_property_not_found
public void Configure_should_throw_when_key_property_not_found()
{
var entityType = new EntityType("E", "N", DataSpace.CSpace);
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
var mockPropertyInfo = new MockPropertyInfo(typeof(int), "Id");
entityTypeConfiguration.Key(mockPropertyInfo);
Assert.Equal(
Strings.KeyPropertyNotFound(("Id"), "E"),
Assert.Throws<InvalidOperationException>(
() => entityTypeConfiguration.Configure(entityType, new EdmModel(DataSpace.CSpace))).Message);
}
示例5: Configure_should_throw_when_key_properties_and_not_root_type
public void Configure_should_throw_when_key_properties_and_not_root_type()
{
var entityType = new EntityType("E", "N", DataSpace.CSpace)
{
BaseType = new EntityType("E", "N", DataSpace.CSpace)
};
var type = typeof(string);
entityType.BaseType.GetMetadataProperties().SetClrType(type);
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
entityTypeConfiguration.Key(new MockPropertyInfo(typeof(int), "Id"));
Assert.Equal(
Strings.KeyRegisteredOnDerivedType(typeof(object), typeof(string)),
Assert.Throws<InvalidOperationException>(
() => entityTypeConfiguration.Configure(entityType, new EdmModel(DataSpace.CSpace))).Message);
}
示例6: Configure_should_configure_and_order_keys_when_keys_and_order_specified
public void Configure_should_configure_and_order_keys_when_keys_and_order_specified()
{
var entityType = new EntityType("E", "N", DataSpace.CSpace);
var property = EdmProperty.CreatePrimitive("P2", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));
entityType.AddMember(property);
var property1 = EdmProperty.CreatePrimitive("P1", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));
entityType.AddMember(property1);
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
var mockPropertyInfo2 = new MockPropertyInfo(typeof(int), "P2");
entityTypeConfiguration.Key(mockPropertyInfo2);
entityTypeConfiguration.Property(new PropertyPath(mockPropertyInfo2)).ColumnOrder = 1;
(entityType.GetDeclaredPrimitiveProperties().SingleOrDefault(p => p.Name == "P2")).SetClrPropertyInfo(mockPropertyInfo2);
var mockPropertyInfo1 = new MockPropertyInfo(typeof(int), "P1");
entityTypeConfiguration.Key(mockPropertyInfo1);
entityTypeConfiguration.Property(new PropertyPath(mockPropertyInfo1)).ColumnOrder = 0;
(entityType.GetDeclaredPrimitiveProperties().SingleOrDefault(p => p.Name == "P1")).SetClrPropertyInfo(mockPropertyInfo1);
entityTypeConfiguration.Configure(entityType, new EdmModel(DataSpace.CSpace));
Assert.Equal(2, entityType.KeyProperties.Count);
Assert.Equal("P1", entityType.KeyProperties.First().Name);
}
示例7: Configure_should_throw_when_property_not_found
public void Configure_should_throw_when_property_not_found()
{
var entityType = new EntityType("E", "N", DataSpace.CSpace);
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
var mockPropertyConfiguration = new Mock<PrimitivePropertyConfiguration>();
entityTypeConfiguration.Property(new PropertyPath(new MockPropertyInfo()), () => mockPropertyConfiguration.Object);
Assert.Equal(
Strings.PropertyNotFound(("P"), "E"),
Assert.Throws<InvalidOperationException>(
() => entityTypeConfiguration.Configure(entityType, new EdmModel(DataSpace.CSpace))).Message);
}
示例8: Configure_should_configure_properties
public void Configure_should_configure_properties()
{
var entityType = new EntityType("E", "N", DataSpace.CSpace);
var property = EdmProperty.CreatePrimitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));
entityType.AddMember(property);
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
var mockPropertyConfiguration = new Mock<PrimitivePropertyConfiguration>();
var mockPropertyInfo = new MockPropertyInfo();
property.SetClrPropertyInfo(mockPropertyInfo);
entityTypeConfiguration.Property(new PropertyPath(mockPropertyInfo), () => mockPropertyConfiguration.Object);
entityTypeConfiguration.Configure(entityType, new EdmModel(DataSpace.CSpace));
mockPropertyConfiguration.Verify(p => p.Configure(property));
}