本文整理汇总了C#中TypeMapper.MapEntityType方法的典型用法代码示例。如果您正苦于以下问题:C# TypeMapper.MapEntityType方法的具体用法?C# TypeMapper.MapEntityType怎么用?C# TypeMapper.MapEntityType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeMapper
的用法示例。
在下文中一共展示了TypeMapper.MapEntityType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MapEntityType_should_not_map_invalid_structural_type
public void MapEntityType_should_not_map_invalid_structural_type()
{
var model = new EdmModel(DataSpace.CSpace);
var typeMapper = new TypeMapper(new MappingContext(new ModelConfiguration(), new ConventionsConfiguration(), model));
Assert.Null(typeMapper.MapEntityType(typeof(string)));
}
示例2: MapEntityType_should_not_map_ignored_type
public void MapEntityType_should_not_map_ignored_type()
{
var model = new EdmModel(DataSpace.CSpace);
var mockModelConfiguration = new Mock<ModelConfiguration>();
var typeMapper = new TypeMapper(new MappingContext(mockModelConfiguration.Object, new ConventionsConfiguration(), model));
mockModelConfiguration.Setup(m => m.IsIgnoredType(typeof(AType1))).Returns(true);
var entityType = typeMapper.MapEntityType(typeof(AType1));
Assert.Null(entityType);
}
示例3: MapEntityType_should_not_bring_in_base_class_by_default
public void MapEntityType_should_not_bring_in_base_class_by_default()
{
var model = new EdmModel(DataSpace.CSpace);
var typeMapper = new TypeMapper(new MappingContext(new ModelConfiguration(), new ConventionsConfiguration(), model));
var entityType = typeMapper.MapEntityType(typeof(AType3));
Assert.NotNull(entityType);
Assert.Null(entityType.BaseType);
Assert.Equal(1, model.EntityTypes.Count());
Assert.Equal(1, model.Containers.Single().EntitySets.Count);
Assert.Equal("AType3", model.GetEntitySet(entityType).Name);
}
示例4: MapEntityType_should_not_bring_in_base_class_by_default
public void MapEntityType_should_not_bring_in_base_class_by_default()
{
var model = new EdmModel().Initialize();
var typeMapper = new TypeMapper(new MappingContext(new ModelConfiguration(), new ConventionsConfiguration(), model));
var mockType = new MockType("Bar").BaseType(new MockType("Foo"));
var entityType = typeMapper.MapEntityType(mockType);
Assert.NotNull(entityType);
Assert.Null(entityType.BaseType);
Assert.Equal(1, model.Namespaces.Single().EntityTypes.Count);
Assert.Equal(1, model.Containers.Single().EntitySets.Count);
Assert.Equal("Bar", model.GetEntitySet(entityType).Name);
}
示例5: MapEntityType_should_create_entity_type_with_clr_type_name_and_add_to_model
public void MapEntityType_should_create_entity_type_with_clr_type_name_and_add_to_model()
{
var model = new EdmModel(DataSpace.CSpace);
var typeMapper = new TypeMapper(new MappingContext(new ModelConfiguration(), new ConventionsConfiguration(), model));
var mockType = new MockType("Foo");
var entityType = typeMapper.MapEntityType(mockType);
Assert.NotNull(entityType);
Assert.Same(entityType, model.GetEntityType("Foo"));
}
示例6: MapEntityType_should_create_entity_set_and_add_to_model
public void MapEntityType_should_create_entity_set_and_add_to_model()
{
var model = new EdmModel(DataSpace.CSpace);
var typeMapper = new TypeMapper(new MappingContext(new ModelConfiguration(), new ConventionsConfiguration(), model));
var mockType = new MockType("Foo");
var entityType = typeMapper.MapEntityType(mockType);
var entitySet = model.GetEntitySet(entityType);
Assert.NotNull(entitySet);
Assert.Same(entityType, entitySet.ElementType);
Assert.Equal("Foo", entitySet.Name);
}
示例7: MapEntityType_should_create_abstract_entity_when_clr_type_is_abstract
public void MapEntityType_should_create_abstract_entity_when_clr_type_is_abstract()
{
var model = new EdmModel(DataSpace.CSpace);
var typeMapper = new TypeMapper(new MappingContext(new ModelConfiguration(), new ConventionsConfiguration(), model));
var mockType = new MockType("Foo").TypeAttributes(TypeAttributes.Abstract);
var entityType = typeMapper.MapEntityType(mockType);
Assert.NotNull(entityType);
Assert.True(entityType.Abstract);
}
示例8: MapEntityType_should_set_namespace_when_provided_via_model_configuration
public void MapEntityType_should_set_namespace_when_provided_via_model_configuration()
{
var model = new EdmModel(DataSpace.CSpace);
var typeMapper
= new TypeMapper(
new MappingContext(
new ModelConfiguration
{
ModelNamespace = "Bar"
},
new ConventionsConfiguration(), model));
var mockType = new MockType("Foo").TypeAttributes(TypeAttributes.Abstract);
var entityType = typeMapper.MapEntityType(mockType);
Assert.NotNull(entityType);
Assert.Equal("Bar", entityType.NamespaceName);
}
示例9: MapEnumType_should_should_throw_for_new_type_if_entity_type_with_same_simple_name_already_used
public void MapEnumType_should_should_throw_for_new_type_if_entity_type_with_same_simple_name_already_used()
{
var model = new EdmModel(DataSpace.CSpace);
var mockType1 = new MockType("Foo");
var mockType2 = new MockType("Foo");
mockType2.SetupGet(t => t.IsEnum).Returns(true);
var typeMapper = new TypeMapper(new MappingContext(new ModelConfiguration(), new ConventionsConfiguration(), model));
Assert.NotNull(typeMapper.MapEntityType(mockType1));
Assert.Equal(
Strings.SimpleNameCollision("Foo", "Foo", "Foo"),
Assert.Throws<NotSupportedException>(() => typeMapper.MapEnumType(mockType2)).Message);
}
示例10: MapEntityType_should_correctly_map_properties_in_class_hierachy
public void MapEntityType_should_correctly_map_properties_in_class_hierachy()
{
var model = new EdmModel(DataSpace.CSpace);
var typeMapper = new TypeMapper(new MappingContext(new ModelConfiguration(), new ConventionsConfiguration(), model));
var mockObjectType = new MockType("Object");
var mockBaseType = new MockType("Foo").BaseType(mockObjectType).Property<int>("Id");
var mockType = new MockType("Bar").BaseType(mockBaseType).Property<string>("Baz");
new MockAssembly(mockObjectType, mockBaseType, mockType);
var entityType = typeMapper.MapEntityType(mockType);
var baseEntityType = typeMapper.MapEntityType(mockBaseType);
Assert.Equal(1, baseEntityType.DeclaredProperties.Count);
Assert.Same(baseEntityType, entityType.BaseType);
Assert.Equal(1, entityType.DeclaredProperties.Count);
Assert.Equal(1, model.Containers.Single().EntitySets.Count);
}
示例11: MapEntityType_should_recognize_StoreIgnore_over_StoreInline
public void MapEntityType_should_recognize_StoreIgnore_over_StoreInline()
{
var type = typeof(TypeMapper_EntityWithStoreInlineAndStoreIgnore);
var model = new EdmModel(DataSpace.CSpace);
var modelConfiguration = new ModelConfiguration();
var typeMapper = new TypeMapper(new MappingContext(modelConfiguration, new ConventionsConfiguration(), model));
typeMapper.MapEntityType(type);
Assert.True(modelConfiguration.IsIgnoredType(type));
Assert.Equal(0, model.EntityTypes.Count());
Assert.Equal(0, model.ComplexTypes.Count());
}
示例12: MapEntityType_should_bring_in_derived_types_from_discovered_assemblies
public void MapEntityType_should_bring_in_derived_types_from_discovered_assemblies()
{
var model = new EdmModel(DataSpace.CSpace);
var typeMapper = new TypeMapper(new MappingContext(new ModelConfiguration(), new ConventionsConfiguration(), model));
Assert.NotSame(typeof(AType9).Assembly(), typeof(Product).Assembly());
typeMapper.MapEntityType(typeof(CType9));
Assert.Equal(1, model.EntityTypes.Count());
Assert.Equal(1, model.Containers.Single().EntitySets.Count);
typeMapper.MapEntityType(typeof(ExtraEntity));
Assert.Equal(3, model.EntityTypes.Count());
Assert.Equal(2, model.Containers.Single().EntitySets.Count);
}
示例13: MapEntityType_should_not_create_entity_type_if_type_already_exists
public void MapEntityType_should_not_create_entity_type_if_type_already_exists()
{
var model = new EdmModel(DataSpace.CSpace);
var typeMapper = new TypeMapper(new MappingContext(new ModelConfiguration(), new ConventionsConfiguration(), model));
var mockType = new MockType("Foo");
typeMapper.MapEntityType(mockType);
typeMapper.MapEntityType(mockType);
Assert.Equal(1, model.EntityTypes.Count());
}
示例14: MapEntityType_with_configured_Entity_should_throw_with_StoreInline
public void MapEntityType_with_configured_Entity_should_throw_with_StoreInline()
{
var type = typeof(TypeMapper_EntityWithStoreInline);
var model = new EdmModel(DataSpace.CSpace);
var modelConfiguration = new ModelConfiguration();
modelConfiguration.Entity(typeof(TypeMapper_EntityWithStoreInline));
var typeMapper = new TypeMapper(new MappingContext(modelConfiguration, new ConventionsConfiguration(), model));
Assert.Equal(
Strings.ComplexTypeConfigurationMismatch(type),
Assert.Throws<InvalidOperationException>(() => typeMapper.MapEntityType(type)).Message);
}
示例15: MapEntityType_should_recognize_StoreInline
public void MapEntityType_should_recognize_StoreInline()
{
var type = typeof(TypeMapper_EntityWithStoreInline);
var model = new EdmModel().Initialize();
var modelConfiguration = new ModelConfiguration();
var typeMapper = new TypeMapper(new MappingContext(modelConfiguration, new ConventionsConfiguration(), model));
typeMapper.MapEntityType(type);
Assert.True(modelConfiguration.IsComplexType(type));
Assert.Equal(0, model.Namespaces.Single().EntityTypes.Count);
Assert.Equal(0, model.Namespaces.Single().ComplexTypes.Count);
}