本文整理汇总了C#中System.Data.Entity.Edm.EdmEntityType.SetClrType方法的典型用法代码示例。如果您正苦于以下问题:C# EdmEntityType.SetClrType方法的具体用法?C# EdmEntityType.SetClrType怎么用?C# EdmEntityType.SetClrType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.Entity.Edm.EdmEntityType
的用法示例。
在下文中一共展示了EdmEntityType.SetClrType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply_should_move_declared_keys_head_of_declared_properties_list
public void Apply_should_move_declared_keys_head_of_declared_properties_list()
{
var entityType = new EdmEntityType();
entityType.SetClrType(typeof(SimpleEntity));
entityType.AddPrimitiveProperty("StaticProperty");
entityType.AddPrimitiveProperty("PrivateProperty");
entityType.AddPrimitiveProperty("InheritedPropertyB");
entityType.AddPrimitiveProperty("InheritedPropertyA");
entityType.AddPrimitiveProperty("PropertyB");
entityType.AddPrimitiveProperty("PropertyA");
entityType.DeclaredKeyProperties.Add(
entityType.AddPrimitiveProperty("Key"));
((IEdmConvention<EdmEntityType>)new DeclaredPropertyOrderingConvention())
.Apply(entityType, new EdmModel());
Assert.True(
entityType.DeclaredProperties.Select(e => e.Name)
.SequenceEqual(
new[]
{
"Key", "PrivateProperty", "PropertyA", "PropertyB", "InheritedPropertyA", "InheritedPropertyB",
"StaticProperty"
}));
}
示例2: Can_get_and_set_clr_type_annotation
public void Can_get_and_set_clr_type_annotation()
{
var entityType = new EdmEntityType();
Assert.Null(entityType.GetClrType());
entityType.SetClrType(typeof(object));
Assert.Equal(typeof(object), entityType.GetClrType());
}
示例3: Entity
public TestModelBuilder Entity(string name, bool addSet = true)
{
_entityType = _model.AddEntityType(name);
_entityType.SetClrType(new MockType(name));
if (addSet)
{
_model.AddEntitySet(name + "Set", _entityType);
}
return this;
}
示例4: Generate_should_add_set_mapping_and_table_and_set_clr_type
public void Generate_should_add_set_mapping_and_table_and_set_clr_type()
{
var databaseMapping = CreateEmptyModel();
var entityType = new EdmEntityType { Name = "E" };
var entitySet = databaseMapping.Model.AddEntitySet("ESet", entityType);
entityType.SetClrType(typeof(object));
new EntityTypeMappingGenerator(ProviderRegistry.Sql2008_ProviderManifest).Generate(entityType, databaseMapping);
Assert.NotNull(databaseMapping.GetEntitySetMapping(entitySet));
Assert.Same(entityType, databaseMapping.GetEntitySetMapping(entitySet).EntityTypeMappings.Single().EntityType);
Assert.Same(typeof(object), databaseMapping.GetEntitySetMapping(entitySet).EntityTypeMappings.Single().GetClrType());
Assert.NotNull(databaseMapping.GetEntitySetMapping(entitySet).EntityTypeMappings.Single().TypeMappingFragments.Single().Table);
}
示例5: Generate_should_map_scalar_properties_to_columns
public void Generate_should_map_scalar_properties_to_columns()
{
var databaseMapping = CreateEmptyModel();
var entityType = new EdmEntityType { Name = "E" };
entityType.AddPrimitiveProperty("P1").PropertyType.EdmType = EdmPrimitiveType.Int32;
entityType.AddPrimitiveProperty("P2").PropertyType.EdmType = EdmPrimitiveType.String;
var entitySet = databaseMapping.Model.AddEntitySet("ESet", entityType);
entityType.SetClrType(typeof(object));
new EntityTypeMappingGenerator(ProviderRegistry.Sql2008_ProviderManifest).Generate(entityType, databaseMapping);
var entityTypeMappingFragment
= databaseMapping.GetEntitySetMapping(entitySet).EntityTypeMappings.Single().TypeMappingFragments.Single();
Assert.Equal(2, entityTypeMappingFragment.PropertyMappings.Count());
Assert.Equal(2, entityTypeMappingFragment.Table.Columns.Count());
}
示例6: GetEntityTypeMapping_should_return_mapping_for_type_by_clrType
public void GetEntityTypeMapping_should_return_mapping_for_type_by_clrType()
{
var databaseMapping = new DbDatabaseMapping()
.Initialize(new EdmModel().Initialize(), new DbDatabaseMetadata());
var entityType = new EdmEntityType { Name = "Foo" };
entityType.SetClrType(typeof(object));
var entityTypeMapping = new DbEntityTypeMapping { EntityType = entityType };
entityTypeMapping.SetClrType(typeof(object));
databaseMapping.AddEntitySetMapping(new EdmEntitySet()).EntityTypeMappings.Add(entityTypeMapping);
Assert.Same(entityTypeMapping, databaseMapping.GetEntityTypeMapping(typeof(object)));
}