Exemple #1
0
        // <summary>
        // For a given edmType, build an array of scalarColumnMaps that map to the columns
        // in the store datareader provided.  Note that we're hooking things up by name, not
        // by ordinal position.
        // </summary>
        private static ColumnMap[] GetColumnMapsForType(
            DbDataReader storeDataReader, EdmType edmType,
            Dictionary <string, FunctionImportReturnTypeStructuralTypeColumnRenameMapping> renameList)
        {
            // First get the list of properties; NOTE: we need to hook up the column by name,
            // not by position.
            var members            = TypeHelpers.GetAllStructuralMembers(edmType);
            var propertyColumnMaps = new ColumnMap[members.Count];

            var index = 0;

            foreach (EdmMember member in members)
            {
                if (!Helper.IsScalarType(member.TypeUsage.EdmType))
                {
                    throw new InvalidOperationException(
                              Strings.ADP_InvalidDataReaderUnableToMaterializeNonScalarType(member.Name, member.TypeUsage.EdmType.FullName));
                }

                var ordinal = GetMemberOrdinalFromReader(storeDataReader, member, edmType, renameList);

                propertyColumnMaps[index] = new ScalarColumnMap(member.TypeUsage, member.Name, 0, ordinal);
                index++;
            }
            return(propertyColumnMaps);
        }
        private static ColumnMap[] GetColumnMapsForType(
            DbDataReader storeDataReader,
            EdmType edmType,
            Dictionary <string, FunctionImportReturnTypeStructuralTypeColumnRenameMapping> renameList)
        {
            IBaseList <EdmMember> structuralMembers = TypeHelpers.GetAllStructuralMembers(edmType);

            ColumnMap[] columnMapArray = new ColumnMap[structuralMembers.Count];
            int         index          = 0;

            foreach (EdmMember member in (IEnumerable)structuralMembers)
            {
                if (!Helper.IsScalarType(member.TypeUsage.EdmType))
                {
                    throw new InvalidOperationException(Strings.ADP_InvalidDataReaderUnableToMaterializeNonScalarType((object)member.Name, (object)member.TypeUsage.EdmType.FullName));
                }
                int ordinalFromReader = ColumnMapFactory.GetMemberOrdinalFromReader(storeDataReader, member, edmType, renameList);
                columnMapArray[index] = (ColumnMap) new ScalarColumnMap(member.TypeUsage, member.Name, 0, ordinalFromReader);
                ++index;
            }
            return(columnMapArray);
        }