本文整理汇总了C#中System.Data.Entity.Core.Metadata.Edm.EntityType.GetCollectionType方法的典型用法代码示例。如果您正苦于以下问题:C# EntityType.GetCollectionType方法的具体用法?C# EntityType.GetCollectionType怎么用?C# EntityType.GetCollectionType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.Entity.Core.Metadata.Edm.EntityType
的用法示例。
在下文中一共展示了EntityType.GetCollectionType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EdmProperty
public void WriteFunctionImportMappingElement_writes_result_mapping_for_non_composable_functions_mapped_explicitly_to_EntityType()
{
var typeUsage =
TypeUsage.CreateDefaultTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32));
var entityTypeProperty1 = new EdmProperty("ETProperty1", typeUsage);
var entityTypeProperty2 = new EdmProperty("ETProperty2", typeUsage);
var entityType = new EntityType("ET", "Ns", DataSpace.CSpace);
entityType.AddMember(entityTypeProperty1);
entityType.AddMember(entityTypeProperty2);
var functionImport =
new EdmFunction(
"f_c", "Ns", DataSpace.CSpace,
new EdmFunctionPayload
{
IsComposable = false,
IsFunctionImport = true,
ReturnParameters =
new[]
{
new FunctionParameter(
"ReturnValue",
TypeUsage.CreateDefaultTypeUsage(entityType.GetCollectionType()),
ParameterMode.ReturnValue)
},
});
typeUsage = ProviderRegistry.Sql2008_ProviderManifest.GetStoreType(typeUsage);
var rowTypeProperty1 = new EdmProperty("RTProperty1", typeUsage);
var rowTypeProperty2 = new EdmProperty("RTProperty2", typeUsage);
var rowType = new RowType(new[] { rowTypeProperty1, rowTypeProperty2 });
var storeFunction =
new EdmFunction(
"f_s", "Ns.Store", DataSpace.SSpace,
new EdmFunctionPayload
{
IsComposable = false,
ReturnParameters =
new[]
{
new FunctionParameter(
"Return",
TypeUsage.CreateDefaultTypeUsage(rowType),
ParameterMode.ReturnValue)
},
});
var functionImportResultMapping = new FunctionImportResultMapping();
functionImportResultMapping.AddTypeMapping(
new FunctionImportEntityTypeMapping(
new EntityType[0],
new [] { entityType },
new Collections.ObjectModel.Collection<FunctionImportReturnTypePropertyMapping>()
{
new FunctionImportReturnTypeScalarPropertyMapping("ETProperty1", "RTProperty1"),
new FunctionImportReturnTypeScalarPropertyMapping("ETProperty2", "RTProperty2")
},
new FunctionImportEntityTypeMappingCondition[]
{
new FunctionImportEntityTypeMappingConditionIsNull("RTProperty1", false),
new FunctionImportEntityTypeMappingConditionValue("RTProperty2", 4),
new FunctionImportEntityTypeMappingConditionValue("FakeCondition", true)
}
));
var mappingItemCollection =
new StorageMappingItemCollection(
new EdmItemCollection(EdmModel.CreateConceptualModel()),
new StoreItemCollection(
EdmModel.CreateStoreModel(ProviderRegistry.Sql2008_ProviderInfo, ProviderRegistry.Sql2008_ProviderManifest)),
new string[0]);
var containerMapping =
new EntityContainerMapping(
new EntityContainer("C", DataSpace.CSpace), new EntityContainer("S", DataSpace.SSpace), mappingItemCollection, false);
var functionImportMapping =
new FunctionImportMappingNonComposable(
functionImport,
storeFunction,
new []
{
functionImportResultMapping
},
containerMapping);
containerMapping.AddFunctionImportMapping(functionImportMapping);
var fixture = new Fixture();
fixture.Writer.WriteFunctionImportMappingElement(functionImportMapping);
Assert.Equal(
@"<FunctionImportMapping FunctionName=""Ns.Store.f_s"" FunctionImportName=""f_c"">
<ResultMapping>
<EntityTypeMapping TypeName=""Ns.ET"">
<ScalarProperty Name=""ETProperty1"" ColumnName=""RTProperty1"" />
<ScalarProperty Name=""ETProperty2"" ColumnName=""RTProperty2"" />
<Condition ColumnName=""RTProperty1"" IsNull=""false"" />
//.........这里部分代码省略.........
示例2: WriteEntityContainerMappingElement_should_write_function_import_elements_mapped_to_EntityType
public void WriteEntityContainerMappingElement_should_write_function_import_elements_mapped_to_EntityType()
{
var typeUsage =
TypeUsage.CreateDefaultTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32));
var entityTypeProperty1 = new EdmProperty("ETProperty1", typeUsage);
var entityTypeProperty2 = new EdmProperty("ETProperty2", typeUsage);
var entityType = new EntityType("ET", "Ns", DataSpace.CSpace);
entityType.AddMember(entityTypeProperty1);
entityType.AddMember(entityTypeProperty2);
var functionImport =
new EdmFunction(
"f_c", "Ns", DataSpace.CSpace,
new EdmFunctionPayload
{
IsComposable = true,
IsFunctionImport = true,
ReturnParameters =
new[]
{
new FunctionParameter(
"ReturnValue",
TypeUsage.CreateDefaultTypeUsage(entityType.GetCollectionType()),
ParameterMode.ReturnValue)
},
Parameters =
new[]
{
new FunctionParameter("param", typeUsage, ParameterMode.Out)
}
});
typeUsage = ProviderRegistry.Sql2008_ProviderManifest.GetStoreType(typeUsage);
var rowTypeProperty1 = new EdmProperty("RTProperty1", typeUsage);
var rowTypeProperty2 = new EdmProperty("RTProperty2", typeUsage);
var rowType = new RowType(new[] { rowTypeProperty1, rowTypeProperty2 });
var storeFunction =
new EdmFunction(
"f_s", "Ns.Store", DataSpace.SSpace,
new EdmFunctionPayload
{
ReturnParameters =
new[]
{
new FunctionParameter(
"Return",
TypeUsage.CreateDefaultTypeUsage(rowType),
ParameterMode.ReturnValue)
},
Parameters =
new[]
{
new FunctionParameter("param", typeUsage, ParameterMode.Out)
}
});
var structuralTypeMapping =
new Tuple<StructuralType, List<ConditionPropertyMapping>, List<PropertyMapping>>(
entityType, new List<ConditionPropertyMapping>(), new List<PropertyMapping>());
structuralTypeMapping.Item2.Add(new ConditionPropertyMapping(rowTypeProperty1, null, false));
structuralTypeMapping.Item3.Add(new ScalarPropertyMapping(entityTypeProperty1, rowTypeProperty1));
structuralTypeMapping.Item3.Add(new ScalarPropertyMapping(entityTypeProperty2, rowTypeProperty2));
var functionImportMapping = new FunctionImportMappingComposable(
functionImport,
storeFunction,
new List<Tuple<StructuralType, List<ConditionPropertyMapping>, List<PropertyMapping>>>
{
structuralTypeMapping
});
var containerMapping = new EntityContainerMapping(new EntityContainer("C", DataSpace.SSpace));
containerMapping.AddFunctionImportMapping(functionImportMapping);
var fixture = new Fixture();
fixture.Writer.WriteEntityContainerMappingElement(containerMapping);
Assert.Equal(
@"<EntityContainerMapping StorageEntityContainer="""" CdmEntityContainer=""C"">
<FunctionImportMapping FunctionName=""Ns.Store.f_s"" FunctionImportName=""f_c"">
<ResultMapping>
<EntityTypeMapping TypeName=""Ns.ET"">
<Condition IsNull=""false"" ColumnName=""RTProperty1"" />
<ScalarProperty Name=""ETProperty1"" ColumnName=""RTProperty1"" />
<ScalarProperty Name=""ETProperty2"" ColumnName=""RTProperty2"" />
</EntityTypeMapping>
</ResultMapping>
</FunctionImportMapping>
</EntityContainerMapping>",
fixture.ToString());
}