本文整理汇总了C#中System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.ComplexType方法的典型用法代码示例。如果您正苦于以下问题:C# ModelConfiguration.ComplexType方法的具体用法?C# ModelConfiguration.ComplexType怎么用?C# ModelConfiguration.ComplexType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration
的用法示例。
在下文中一共展示了ModelConfiguration.ComplexType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Add_complex_type_configuration_should_add_to_model_configuration
public void Add_complex_type_configuration_should_add_to_model_configuration()
{
var modelConfiguration = new ModelConfiguration();
var complexTypeConfiguration = new ComplexTypeConfiguration<object>();
new ConfigurationRegistrar(modelConfiguration).Add(complexTypeConfiguration);
Assert.Same(complexTypeConfiguration.Configuration, modelConfiguration.ComplexType(typeof(object)));
}
示例2: AddConfigurationTypesToModel_adds_complextypeconfigurations_into_model
public void AddConfigurationTypesToModel_adds_complextypeconfigurations_into_model()
{
var complexTypeConfiguration = new ComplexTypeConfiguration(typeof(Random));
var filter = new Mock<ConfigurationTypeFilter>();
filter.Setup(f => f.IsEntityTypeConfiguration(It.IsAny<Type>())).Returns(false);
filter.Setup(f => f.IsComplexTypeConfiguration(It.IsAny<Type>())).Returns(true);
var activator = new Mock<ConfigurationTypeActivator>();
activator.Setup(a => a.Activate<ComplexTypeConfiguration>(It.IsAny<Type>()))
.Returns(complexTypeConfiguration);
var finder = new ConfigurationTypesFinder(activator.Object, filter.Object);
var modelConfiguration = new ModelConfiguration();
finder.AddConfigurationTypesToModel(new[] { typeof(Object) }, modelConfiguration);
Assert.Same(complexTypeConfiguration, modelConfiguration.ComplexType(typeof(Random)));
}
示例3: ComplexType_should_throw_when_configuration_is_not_for_complex_type
public void ComplexType_should_throw_when_configuration_is_not_for_complex_type()
{
var modelConfiguration = new ModelConfiguration();
modelConfiguration.Add(new Mock<EntityTypeConfiguration>(typeof(object)).Object);
Assert.Equal(
Strings.ComplexTypeConfigurationMismatch(typeof(object).Name),
Assert.Throws<InvalidOperationException>(() => modelConfiguration.ComplexType(typeof(object))).Message);
}
示例4: ComplexType_should_return_new_configuration_if_no_configuration_found
public void ComplexType_should_return_new_configuration_if_no_configuration_found()
{
var modelConfiguration = new ModelConfiguration();
Assert.NotNull(modelConfiguration.ComplexType(typeof(object)));
}
示例5: Can_add_and_get_complex_type_configuration
public void Can_add_and_get_complex_type_configuration()
{
var modelConfiguration = new ModelConfiguration();
var complexTypeConfiguration = new Mock<ComplexTypeConfiguration>(typeof(object)).Object;
modelConfiguration.Add(complexTypeConfiguration);
Assert.Same(complexTypeConfiguration, modelConfiguration.ComplexType(typeof(object)));
}
示例6: ComplexTypes_returns_only_configured_non_ignored_complex_types
public void ComplexTypes_returns_only_configured_non_ignored_complex_types()
{
var modelConfiguration = new ModelConfiguration();
modelConfiguration.Entity(new MockType());
var mockComplexType = new MockType();
modelConfiguration.ComplexType(mockComplexType);
var mockIgnoredComplexType = new MockType();
modelConfiguration.ComplexType(mockIgnoredComplexType);
modelConfiguration.Ignore(mockIgnoredComplexType);
Assert.Same(mockComplexType.Object, modelConfiguration.ComplexTypes.Single());
}
示例7: ConfiguredTypes_returns_all_known_types
public void ConfiguredTypes_returns_all_known_types()
{
var modelConfiguration = new ModelConfiguration();
modelConfiguration.Entity(new MockType());
modelConfiguration.ComplexType(new MockType());
modelConfiguration.Ignore(new MockType());
Assert.Equal(3, modelConfiguration.ConfiguredTypes.Count());
}
示例8: MapComplexType_should_set_namespace_when_provided_via_model_configuration
public void MapComplexType_should_set_namespace_when_provided_via_model_configuration()
{
var model = new EdmModel(DataSpace.CSpace);
var mockType = new MockType("Foo");
var modelConfiguration = new ModelConfiguration
{
ModelNamespace = "Bar"
};
modelConfiguration.ComplexType(mockType);
var typeMapper = new TypeMapper(new MappingContext(modelConfiguration, new ConventionsConfiguration(), model));
var complexType = typeMapper.MapComplexType(mockType);
Assert.NotNull(complexType);
Assert.Equal("Bar", complexType.NamespaceName);
}
示例9: MapComplexType_should_create_complex_type_with_clr_type_name_and_add_to_model
public void MapComplexType_should_create_complex_type_with_clr_type_name_and_add_to_model()
{
var model = new EdmModel(DataSpace.CSpace);
var mockType = new MockType("Foo");
var modelConfiguration = new ModelConfiguration();
modelConfiguration.ComplexType(mockType);
var typeMapper = new TypeMapper(new MappingContext(modelConfiguration, new ConventionsConfiguration(), model));
var complexType = typeMapper.MapComplexType(mockType);
Assert.NotNull(complexType);
Assert.Same(complexType, model.GetComplexType("Foo"));
}
示例10: MapEnumType_should_should_throw_for_new_type_if_complex_type_with_same_simple_name_already_used
public void MapEnumType_should_should_throw_for_new_type_if_complex_type_with_same_simple_name_already_used()
{
var model = new EdmModel(DataSpace.CSpace);
var mockType1 = new MockType("Foo");
var mockType2 = new MockType("Foo");
var modelConfiguration = new ModelConfiguration();
modelConfiguration.ComplexType(mockType1);
mockType2.SetupGet(t => t.IsEnum).Returns(true);
var typeMapper = new TypeMapper(new MappingContext(modelConfiguration, new ConventionsConfiguration(), model));
Assert.NotNull(typeMapper.MapComplexType(mockType1));
Assert.Equal(
Strings.SimpleNameCollision("Foo", "Foo", "Foo"),
Assert.Throws<NotSupportedException>(() => typeMapper.MapEnumType(mockType2)).Message);
}
示例11: MapComplexType_should_ignore_new_type_if_type_name_already_used
public void MapComplexType_should_ignore_new_type_if_type_name_already_used()
{
var model = new EdmModel().Initialize();
var mockType1 = new MockType("Foo");
var mockType2 = new MockType("Foo");
var modelConfiguration = new ModelConfiguration();
modelConfiguration.ComplexType(mockType1);
modelConfiguration.ComplexType(mockType2);
var typeMapper = new TypeMapper(new MappingContext(modelConfiguration, new ConventionsConfiguration(), model));
Assert.NotNull(typeMapper.MapComplexType(mockType1));
Assert.Null(typeMapper.MapComplexType(mockType2));
}
示例12: MapEnumType_should_should_throw_for_new_type_if_complex_type_with_same_simple_name_already_used
public void MapEnumType_should_should_throw_for_new_type_if_complex_type_with_same_simple_name_already_used()
{
var model = new EdmModel(DataSpace.CSpace);
var modelConfiguration = new ModelConfiguration();
modelConfiguration.ComplexType(typeof(Outer5.AType5));
var typeMapper = new TypeMapper(new MappingContext(modelConfiguration, new ConventionsConfiguration(), model));
Assert.NotNull(typeMapper.MapComplexType(typeof(Outer5.AType5)));
Assert.Equal(
Strings.SimpleNameCollision(typeof(AType5).FullName, typeof(Outer5.AType5).FullName, "AType5"),
Assert.Throws<NotSupportedException>(() => typeMapper.MapEnumType(typeof(AType5))).Message);
}