本文整理汇总了C#中StructuralType.GetCollectionType方法的典型用法代码示例。如果您正苦于以下问题:C# StructuralType.GetCollectionType方法的具体用法?C# StructuralType.GetCollectionType怎么用?C# StructuralType.GetCollectionType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StructuralType
的用法示例。
在下文中一共展示了StructuralType.GetCollectionType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateFunctionImportStructuralTypeColumnMap
/// <summary>
/// Creates a column map for the given reader and function mapping.
/// </summary>
internal virtual CollectionColumnMap CreateFunctionImportStructuralTypeColumnMap(
DbDataReader storeDataReader, FunctionImportMappingNonComposable mapping, int resultSetIndex, EntitySet entitySet,
StructuralType baseStructuralType)
{
var resultMapping = mapping.GetResultMapping(resultSetIndex);
Debug.Assert(resultMapping != null);
if (resultMapping.NormalizedEntityTypeMappings.Count == 0) // no explicit mapping; use default non-polymorphic reader
{
// if there is no mapping, create default mapping to root entity type or complex type
Debug.Assert(!baseStructuralType.Abstract, "mapping loader must verify abstract types have explicit mapping");
return CreateColumnMapFromReaderAndType(
storeDataReader, baseStructuralType, entitySet, resultMapping.ReturnTypeColumnsRenameMapping);
}
// the section below deals with the polymorphic entity type mapping for return type
var baseEntityType = baseStructuralType as EntityType;
Debug.Assert(null != baseEntityType, "We should have entity type here");
// Generate column maps for all discriminators
var discriminatorColumns = CreateDiscriminatorColumnMaps(storeDataReader, mapping, resultSetIndex);
// Generate default maps for all mapped entity types
var mappedEntityTypes = new HashSet<EntityType>(resultMapping.MappedEntityTypes);
mappedEntityTypes.Add(baseEntityType); // make sure the base type is represented
var typeChoices = new Dictionary<EntityType, TypedColumnMap>(mappedEntityTypes.Count);
ColumnMap[] baseTypeColumnMaps = null;
foreach (var entityType in mappedEntityTypes)
{
var propertyColumnMaps = GetColumnMapsForType(storeDataReader, entityType, resultMapping.ReturnTypeColumnsRenameMapping);
var entityColumnMap = CreateEntityTypeElementColumnMap(
storeDataReader, entityType, entitySet, propertyColumnMaps, resultMapping.ReturnTypeColumnsRenameMapping);
if (!entityType.Abstract)
{
typeChoices.Add(entityType, entityColumnMap);
}
if (entityType == baseStructuralType)
{
baseTypeColumnMaps = propertyColumnMaps;
}
}
// NOTE: We don't have a null sentinel here, because the stored proc won't
// return one anyway; we'll just presume the data's always there.
var polymorphicMap = new MultipleDiscriminatorPolymorphicColumnMap(
TypeUsage.Create(baseStructuralType), baseStructuralType.Name, baseTypeColumnMaps, discriminatorColumns, typeChoices,
(object[] discriminatorValues) => mapping.Discriminate(discriminatorValues, resultSetIndex));
CollectionColumnMap collection = new SimpleCollectionColumnMap(
baseStructuralType.GetCollectionType().TypeUsage, baseStructuralType.Name, polymorphicMap, null, null);
return collection;
}