// <summary> // The constructor for MetadataProperty taking in all the ingredients for creating TypeUsage and the actual value // </summary> // <param name="name"> The name of the attribute </param> // <param name="edmType"> The edm type of the attribute </param> // <param name="isCollectionType"> Whether the collection type of the given edm type should be used </param> // <param name="value"> The value of the attribute </param> internal MetadataProperty(string name, EdmType edmType, bool isCollectionType, object value) { DebugCheck.NotNull(edmType); _name = name; _value = value; if (isCollectionType) { _typeUsage = TypeUsage.Create(edmType.GetCollectionType()); } else { _typeUsage = TypeUsage.Create(edmType); } _propertyKind = PropertyKind.System; }
/// <summary> /// The constructor for MetadataProperty taking in all the ingredients for creating TypeUsage and the actual value /// </summary> /// <param name="name">The name of the attribute</param> /// <param name="edmType">The edm type of the attribute</param> /// <param name="isCollectionType">Whether the collection type of the given edm type should be used</param> /// <param name="value">The value of the attribute</param> internal MetadataProperty(string name, EdmType edmType, bool isCollectionType, object value) { Contract.Requires(edmType != null); _name = name; _value = value; if (isCollectionType) { _typeUsage = TypeUsage.Create(edmType.GetCollectionType()); } else { _typeUsage = TypeUsage.Create(edmType); } _propertyKind = PropertyKind.System; }
/// <summary> /// Build the collectionColumnMap from a store datareader, a type and an entitySet. /// </summary> /// <param name="storeDataReader"> </param> /// <param name="edmType"> </param> /// <param name="entitySet"> </param> /// <returns> </returns> internal virtual CollectionColumnMap CreateColumnMapFromReaderAndType( DbDataReader storeDataReader, EdmType edmType, EntitySet entitySet, Dictionary<string, FunctionImportReturnTypeStructuralTypeColumnRenameMapping> renameList) { Debug.Assert( Helper.IsEntityType(edmType) || null == entitySet, "The specified non-null EntitySet is incompatible with the EDM type specified."); // Next, build the ColumnMap directly from the edmType and entitySet provided. var propertyColumnMaps = GetColumnMapsForType(storeDataReader, edmType, renameList); ColumnMap elementColumnMap = null; // 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. if (Helper.IsRowType(edmType)) { elementColumnMap = new RecordColumnMap(TypeUsage.Create(edmType), edmType.Name, propertyColumnMaps, null); } else if (Helper.IsComplexType(edmType)) { elementColumnMap = new ComplexTypeColumnMap(TypeUsage.Create(edmType), edmType.Name, propertyColumnMaps, null); } else if (Helper.IsScalarType(edmType)) { if (storeDataReader.FieldCount != 1) { throw new EntityCommandExecutionException(Strings.ADP_InvalidDataReaderFieldCountForScalarType); } elementColumnMap = new ScalarColumnMap(TypeUsage.Create(edmType), edmType.Name, 0, 0); } else if (Helper.IsEntityType(edmType)) { elementColumnMap = CreateEntityTypeElementColumnMap( storeDataReader, edmType, entitySet, propertyColumnMaps, null /*renameList*/); } else { Debug.Assert(false, "unexpected edmType?"); } CollectionColumnMap collection = new SimpleCollectionColumnMap( edmType.GetCollectionType().TypeUsage, edmType.Name, elementColumnMap, null, null); return collection; }
internal MetadataProperty(string name, EdmType edmType, bool isCollectionType, object value) { this._name = name; this._value = value; this._typeUsage = !isCollectionType?TypeUsage.Create(edmType) : TypeUsage.Create((EdmType)edmType.GetCollectionType()); this._propertyKind = PropertyKind.System; }