src/Shared/EntityFramework/Core/Query/PlanCompiler/ColumnMapProcessor.cs
// <summary>
// Create a column map for a complextype column
// </summary>
// <param name="typeInfo"> Type information for the type </param>
// <param name="name"> column name </param>
// <param name="superTypeColumnMap"> Supertype info if any </param>
// <param name="discriminatorMap"> Dictionary of typeidvalue->column map </param>
// <param name="allMaps"> List of all maps </param>
Create a column map for a complextype column
Create a column map for a complextype column
private ComplexTypeColumnMap CreateComplexTypeColumnMap(
            TypeInfo typeInfo, string name, ComplexTypeColumnMap superTypeColumnMap,
            Dictionary<object, TypedColumnMap> discriminatorMap, List<TypedColumnMap> allMaps)
        {
            var propertyColumnMapList = new List<ColumnMap>();
            IEnumerable myProperties = null;
            SimpleColumnMap nullSentinelColumnMap = null;
            if (typeInfo.HasNullSentinelProperty)
            {
                nullSentinelColumnMap = CreateSimpleColumnMap(
                    md.Helper.GetModelTypeUsage(typeInfo.NullSentinelProperty), c_NullSentinelColumnName);
            }
            if (superTypeColumnMap != null)
            {
                foreach (var c in superTypeColumnMap.Properties)
                {
                    propertyColumnMapList.Add(c);
                }
                myProperties = TypeHelpers.GetDeclaredStructuralMembers(typeInfo.Type);
            }
            else
            {
                myProperties = TypeHelpers.GetAllStructuralMembers(typeInfo.Type);
            }
            foreach (md.EdmMember property in myProperties)
            {
                var propertyColumnMap = CreateColumnMap(md.Helper.GetModelTypeUsage(property), property.Name);
                propertyColumnMapList.Add(propertyColumnMap);
            }
            var columnMap = new ComplexTypeColumnMap(typeInfo.Type, name, propertyColumnMapList.ToArray(), nullSentinelColumnMap);
            if (discriminatorMap != null)
            {
                discriminatorMap[typeInfo.TypeId] = columnMap;
            }
            if (allMaps != null)
            {
                allMaps.Add(columnMap);
            }
            foreach (var subTypeInfo in typeInfo.ImmediateSubTypes)
            {
                CreateComplexTypeColumnMap(subTypeInfo, name, columnMap, discriminatorMap, allMaps);
            }
            return columnMap;
        }
private ComplexTypeColumnMap CreateComplexTypeColumnMap ( TypeInfo typeInfo , string name , ComplexTypeColumnMap superTypeColumnMap , Dictionary < object , TypedColumnMap > discriminatorMap , List < TypedColumnMap > allMaps ) { var propertyColumnMapList = new List < ColumnMap > ( ) ; IEnumerable myProperties = null ; SimpleColumnMap nullSentinelColumnMap = null ; if ( typeInfo . HasNullSentinelProperty ) { nullSentinelColumnMap = CreateSimpleColumnMap ( md . Helper . GetModelTypeUsage ( typeInfo . NullSentinelProperty ) , c_NullSentinelColumnName ) ; } if ( superTypeColumnMap != null ) { foreach ( var c in superTypeColumnMap . Properties ) { propertyColumnMapList . Add ( c ) ; } myProperties = TypeHelpers . GetDeclaredStructuralMembers ( typeInfo . Type ) ; } else { myProperties = TypeHelpers . GetAllStructuralMembers ( typeInfo . Type ) ; } foreach ( md . EdmMember property in myProperties ) { var propertyColumnMap = CreateColumnMap ( md . Helper . GetModelTypeUsage ( property ) , property . Name ) ; propertyColumnMapList . Add ( propertyColumnMap ) ; } var columnMap = new ComplexTypeColumnMap ( typeInfo . Type , name , propertyColumnMapList . ToArray ( ) , nullSentinelColumnMap ) ; if ( discriminatorMap != null ) { discriminatorMap [ typeInfo . TypeId ] = columnMap ; } if ( allMaps != null ) { allMaps . Add ( columnMap ) ; } foreach ( var subTypeInfo in typeInfo . ImmediateSubTypes ) { CreateComplexTypeColumnMap ( subTypeInfo , name , columnMap , discriminatorMap , allMaps ) ; } return columnMap ; }
Create a column map for a complextype column
Create a column map for a complextype column
// Copy over information from my supertype if it already exists // need to get all members otherwise // Now add on all of my "specific" properties // Create a map for myself // if a dictionary is supplied, add myself to the dictionary // Finally walk through my subtypes - use the same column name
typeInfo
TypeInfo
Type information for the type
Type information for the type
name
string
None
superTypeColumnMap
ComplexTypeColumnMap
Supertype info if any
Supertype info if any
discriminatorMap
Dictionary<object, TypedColumnMap>
Dictionary of typeidvalue->column map
Dictionary of typeidvalue - > column map
allMaps
List<TypedColumnMap>
List of all maps
List of all maps