本文整理汇总了C#中System.Data.Entity.Core.Metadata.Edm.EdmModel.AddEntitySet方法的典型用法代码示例。如果您正苦于以下问题:C# EdmModel.AddEntitySet方法的具体用法?C# EdmModel.AddEntitySet怎么用?C# EdmModel.AddEntitySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.Entity.Core.Metadata.Edm.EdmModel
的用法示例。
在下文中一共展示了EdmModel.AddEntitySet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply_should_uniquify_names
public void Apply_should_uniquify_names()
{
var model = new EdmModel(DataSpace.CSpace);
model.AddEntitySet("Cats", new EntityType("E", "N", DataSpace.CSpace));
var entitySet = model.AddEntitySet("Cat", new EntityType("E", "N", DataSpace.CSpace));
(new PluralizingEntitySetNameConvention())
.Apply(entitySet, new DbModel(model, null));
Assert.Equal("Cats1", entitySet.Name);
}
示例2: Apply_should_uniquify_names
public void Apply_should_uniquify_names()
{
var database = new EdmModel(DataSpace.CSpace);
var tableA = new EntityType("T", XmlConstants.TargetNamespace_3, DataSpace.SSpace);
var tableB = new EntityType("T", XmlConstants.TargetNamespace_3, DataSpace.SSpace);
var entitySetA = database.AddEntitySet("ESA", tableA);
entitySetA.Table = "Customers";
var entitySetB = database.AddEntitySet("ESB", tableB);
entitySetB.Table = "Customer";
(new PluralizingTableNameConvention()).Apply(tableB, new DbModel(null, database));
Assert.Equal("Customers1", entitySetB.Table);
}
示例3: Apply_should_uniquify_names_multiple
public void Apply_should_uniquify_names_multiple()
{
var model = new EdmModel(DataSpace.CSpace);
model.AddEntitySet("Cats1", new EntityType("E", "N", DataSpace.CSpace));
var entitySet1 = model.AddEntitySet("Cats", new EntityType("E", "N", DataSpace.CSpace));
var entitySet2 = model.AddEntitySet("Cat", new EntityType("E", "N", DataSpace.CSpace));
((IEdmConvention<EntitySet>)new PluralizingEntitySetNameConvention())
.Apply(entitySet1, model);
((IEdmConvention<EntitySet>)new PluralizingEntitySetNameConvention())
.Apply(entitySet2, model);
Assert.Equal("Cats", entitySet1.Name);
Assert.Equal("Cats2", entitySet2.Name);
}
示例4: 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());
}
示例5: Generate_can_map_a_simple_entity_type_and_set
public void Generate_can_map_a_simple_entity_type_and_set()
{
var model = new EdmModel().Initialize();
var entityType = model.AddEntityType("E");
var type = typeof(object);
entityType.Annotations.SetClrType(type);
var property = EdmProperty.Primitive("P1", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));
entityType.AddMember(property);
var property1 = EdmProperty.Primitive("P2", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));
entityType.AddMember(property1);
var entitySet = model.AddEntitySet("ESet", entityType);
var databaseMapping = new DatabaseMappingGenerator(ProviderRegistry.Sql2008_ProviderManifest).Generate(model);
var entitySetMapping = databaseMapping.GetEntitySetMapping(entitySet);
Assert.NotNull(entitySetMapping);
Assert.Same(entitySet, entitySetMapping.EntitySet);
var entityTypeMapping = entitySetMapping.EntityTypeMappings.Single();
Assert.Same(entityType, entityTypeMapping.EntityType);
Assert.NotNull(entityTypeMapping.MappingFragments.Single().Table);
Assert.Equal("E", entityTypeMapping.MappingFragments.Single().Table.Name);
Assert.Equal(2, entityTypeMapping.MappingFragments.Single().Table.Properties.Count);
Assert.Equal(typeof(object), entityTypeMapping.GetClrType());
}
示例6: Generate_can_map_a_simple_entity_type_and_set
public void Generate_can_map_a_simple_entity_type_and_set()
{
var model = new EdmModel(DataSpace.CSpace);
var entityType = model.AddEntityType("E");
var type = typeof(object);
entityType.GetMetadataProperties().SetClrType(type);
var property = EdmProperty.CreatePrimitive("P1", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));
entityType.AddMember(property);
var property1 = EdmProperty.CreatePrimitive("P2", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));
entityType.AddMember(property1);
var entitySet = model.AddEntitySet("ESet", entityType);
var databaseMapping = CreateDatabaseMappingGenerator().Generate(model);
var entitySetMapping = databaseMapping.GetEntitySetMapping(entitySet);
Assert.NotNull(entitySetMapping);
Assert.Same(entitySet, entitySetMapping.EntitySet);
var entityTypeMapping = entitySetMapping.EntityTypeMappings.Single();
Assert.Same(entityType, entityTypeMapping.EntityType);
Assert.NotNull(entityTypeMapping.MappingFragments.Single().Table);
Assert.Equal("E", entityTypeMapping.MappingFragments.Single().Table.Name);
Assert.Equal(2, entityTypeMapping.MappingFragments.Single().Table.Properties.Count);
Assert.Equal(typeof(object), entityTypeMapping.GetClrType());
}
示例7: Map_should_create_association_sets_for_associations
public void Map_should_create_association_sets_for_associations()
{
var modelConfiguration = new ModelConfiguration();
var model = new EdmModel().Initialize();
var entityType = new EntityType
{
Name = "Source"
};
model.AddEntitySet("Source", entityType);
var mappingContext = new MappingContext(modelConfiguration, new ConventionsConfiguration(), model);
new NavigationPropertyMapper(new TypeMapper(mappingContext))
.Map(
new MockPropertyInfo(new MockType("Target"), "Nav"), entityType,
() => new EntityTypeConfiguration(typeof(object)));
Assert.Equal(1, model.Containers.Single().AssociationSets.Count);
var associationSet = model.Containers.Single().AssociationSets.Single();
Assert.NotNull(associationSet);
Assert.NotNull(associationSet.ElementType);
Assert.Equal("Source_Nav", associationSet.Name);
}
示例8: Apply_should_ignore_current_entity_set
public void Apply_should_ignore_current_entity_set()
{
var model = new EdmModel(DataSpace.CSpace);
var entitySet = model.AddEntitySet("Cats", new EntityType("E", "N", DataSpace.CSpace));
((IEdmConvention<EntitySet>)new PluralizingEntitySetNameConvention())
.Apply(entitySet, model);
Assert.Equal("Cats", entitySet.Name);
}
示例9: Apply_should_ignore_current_table
public void Apply_should_ignore_current_table()
{
var database = new EdmModel(DataSpace.CSpace);
var table = new EntityType("T", XmlConstants.TargetNamespace_3, DataSpace.SSpace);
var entitySet = database.AddEntitySet("ES", table);
entitySet.Table = "Customers";
(new PluralizingTableNameConvention()).Apply(table, new DbModel(null, database));
Assert.Equal("Customers", entitySet.Table);
}
示例10: Apply_should_set_pluralized_table_name_as_identitier
public void Apply_should_set_pluralized_table_name_as_identitier()
{
var database = new EdmModel(DataSpace.CSpace);
var table = new EntityType("T", XmlConstants.TargetNamespace_3, DataSpace.SSpace);
var entitySet = database.AddEntitySet("ES", table);
entitySet.Table = "Customer";
((IDbConvention<EntityType>)new PluralizingTableNameConvention()).Apply(table, database);
Assert.Equal("Customers", entitySet.Table);
}
示例11: Configure_should_uniquify_unconfigured_function_names
public void Configure_should_uniquify_unconfigured_function_names()
{
var modelConfiguration = new ModelConfiguration();
var typeA = new MockType("A");
var typeB = new MockType("B");
modelConfiguration.Entity(typeA).MapToStoredProcedures();
var modificationFunctionsConfiguration
= new ModificationStoredProceduresConfiguration();
var modificationFunctionConfiguration = new ModificationStoredProcedureConfiguration();
modificationFunctionConfiguration.HasName("A_Insert");
modificationFunctionsConfiguration.Insert(modificationFunctionConfiguration);
modelConfiguration.Entity(typeB).MapToStoredProcedures(modificationFunctionsConfiguration, true);
var model = new EdmModel(DataSpace.CSpace);
var entityA = model.AddEntityType("A");
entityA.GetMetadataProperties().SetClrType(typeA);
entityA.SetConfiguration(modelConfiguration.Entity(typeA));
var entityB = model.AddEntityType("B");
entityB.GetMetadataProperties().SetClrType(typeB);
entityB.SetConfiguration(modelConfiguration.Entity(typeB));
model.AddEntitySet("AS", entityA);
model.AddEntitySet("BS", entityB);
var databaseMapping
= new DatabaseMappingGenerator(ProviderRegistry.Sql2008_ProviderInfo, ProviderRegistry.Sql2008_ProviderManifest)
.Generate(model);
modelConfiguration.Configure(databaseMapping, ProviderRegistry.Sql2008_ProviderManifest);
Assert.True(databaseMapping.Database.Functions.Any(f => f.StoreFunctionNameAttribute == "A_Insert"));
Assert.True(databaseMapping.Database.Functions.Any(f => f.StoreFunctionNameAttribute == "A_Insert1"));
}
示例12: Map_should_map_entity_navigation_properties
public void Map_should_map_entity_navigation_properties()
{
var model = new EdmModel(DataSpace.CSpace);
var entityType = new EntityType("E", "N", DataSpace.CSpace);
model.AddEntitySet("Source", entityType);
var mappingContext
= new MappingContext(new ModelConfiguration(), new ConventionsConfiguration(), model);
new PropertyMapper(new TypeMapper(mappingContext))
.Map(new MockPropertyInfo(typeof(AType1), "Foo"), entityType, () => new EntityTypeConfiguration(typeof(object)));
Assert.Equal(1, entityType.DeclaredNavigationProperties.Count);
}
示例13: Apply_should_ignored_configured_tables
public void Apply_should_ignored_configured_tables()
{
var database = new EdmModel(DataSpace.CSpace);
var table = new EntityType("T", XmlConstants.TargetNamespace_3, DataSpace.SSpace);
table.SetTableName(new DatabaseName("Foo"));
var entitySet = database.AddEntitySet("ES", table);
entitySet.Table = "Customer";
((IDbConvention<EntityType>)new PluralizingTableNameConvention()).Apply(table, database);
Assert.Equal("Customer", entitySet.Table);
Assert.Equal("Foo", table.GetTableName().Name);
}
示例14: 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());
}
示例15: CreateSimpleModel
private static DbDatabaseMapping CreateSimpleModel(double version)
{
var model = new EdmModel(DataSpace.CSpace, version);
var entityType = model.AddEntityType("E");
var type = typeof(object);
entityType.GetMetadataProperties().SetClrType(type);
model.AddEntitySet("ESet", entityType);
var property1 = EdmProperty.CreatePrimitive("Id", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));
entityType.AddMember(property1);
var property = property1;
property.Nullable = false;
entityType.AddKeyMember(property);
return new DatabaseMappingGenerator(ProviderRegistry.Sql2008_ProviderInfo, ProviderRegistry.Sql2008_ProviderManifest).Generate(model);
}