// <summary> // Create a simple columnmap - applies only to scalar properties // (Temporarily, also for collections) // Simply picks up the next available column in the reader // </summary> // <param name="type"> Column type </param> // <param name="name"> column name </param> // <returns> Column map for this column </returns> private SimpleColumnMap CreateSimpleColumnMap(md.TypeUsage type, string name) { var newVar = GetNextVar(); SimpleColumnMap result = new VarRefColumnMap(type, name, newVar); return(result); }
// <summary> // Get the "new" type corresponding to the input type. For structured types, // we return the flattened record type. // For collections of structured type, we return a new collection type of the corresponding flattened // type. // For enum types we return the underlying type of the enum type. // For strong spatial types we return the union type that includes the strong spatial type. // For everything else, we return the input type // </summary> // <param name="type"> the original type </param> // <returns> the new type (if any) </returns> private md.TypeUsage GetNewType(md.TypeUsage type) { if (TypeUtils.IsStructuredType(type)) { var typeInfo = GetTypeInfo(type); return(typeInfo.FlattenedTypeUsage); } md.TypeUsage elementType; if (TypeHelpers.TryGetCollectionElementType(type, out elementType)) { var newElementType = GetNewType(elementType); if (newElementType.EdmEquals(elementType)) { return(type); } else { return(TypeHelpers.CreateCollectionTypeUsage(newElementType)); } } if (TypeUtils.IsEnumerationType(type)) { return(TypeHelpers.CreateEnumUnderlyingTypeUsage(type)); } if (md.TypeSemantics.IsStrongSpatialType(type)) { return(TypeHelpers.CreateSpatialUnionTypeUsage(type)); } // simple scalar return(type); }
// <summary> // Is this a structured type? // Note: Structured, in this context means structured outside the server. // UDTs for instance, are considered to be scalar types - all WinFS types, // would by this argument, be scalar types. // </summary> // <param name="type"> The type to check </param> // <returns> true, if the type is a structured type </returns> internal static bool IsStructuredType(md.TypeUsage type) { return(md.TypeSemantics.IsReferenceType(type) || md.TypeSemantics.IsRowType(type) || md.TypeSemantics.IsEntityType(type) || md.TypeSemantics.IsRelationshipType(type) || (md.TypeSemantics.IsComplexType(type))); }
private md.TypeUsage GetPropertyType(RootTypeInfo typeInfo, PropertyRef p) { md.TypeUsage result = null; PropertyRef innerProperty = null; // Get the "leaf" property first while (p is NestedPropertyRef) { var npr = (NestedPropertyRef)p; p = npr.OuterProperty; innerProperty = npr.InnerProperty; } if (p is TypeIdPropertyRef) { // // Get to the innermost type that specifies this typeid (the entity type), // get the datatype for the typeid column from that type // var simplePropertyRef = (SimplePropertyRef)innerProperty; if (simplePropertyRef != null) { var innerType = simplePropertyRef.Property.TypeUsage; var innerTypeInfo = GetTypeInfo(innerType); result = innerTypeInfo.RootType.TypeIdType; } else { result = typeInfo.TypeIdType; } } else if (p is EntitySetIdPropertyRef || p is NullSentinelPropertyRef) { result = m_intType; } else if (p is RelPropertyRef) { result = ((RelPropertyRef)p).Property.ToEnd.TypeUsage; } else { var simpleP = p as SimplePropertyRef; if (simpleP != null) { result = md.Helper.GetModelTypeUsage(simpleP.Property); } } result = GetNewType(result); PlanCompiler.Assert(null != result, "unrecognized property type?"); return(result); }
protected TypeInfo(md.TypeUsage type, TypeInfo superType) { m_type = type; m_immediateSubTypes = new List <TypeInfo>(); m_superType = superType; if (superType != null) { // Add myself to my supertype's list of subtypes superType.m_immediateSubTypes.Add(this); // my supertype's root type is mine as well m_rootType = superType.RootType; } }
protected TypeInfo(md.TypeUsage type, TypeInfo superType) { m_type = type; m_immediateSubTypes = new List<TypeInfo>(); m_superType = superType; if (superType != null) { // Add myself to my supertype's list of subtypes superType.m_immediateSubTypes.Add(this); // my supertype's root type is mine as well m_rootType = superType.RootType; } }
// <summary> // Creates a column map for a column // </summary> // <param name="type"> column datatype </param> // <param name="name"> column name </param> private ColumnMap CreateColumnMap(md.TypeUsage type, string name) { // For simple types, create a simple column map // Temporarily, handle collections exactly the same way if (!TypeUtils.IsStructuredType(type)) { return(CreateSimpleColumnMap(type, name)); } // At this point, we must be dealing with either a record type, a // complex type, or an entity type return(CreateStructuralColumnMap(type, name)); }
private readonly RootTypeInfo m_rootType; // the top-most type in this types type hierarchy #endregion #region Constructors and factory methods // <summary> // Creates type information for a type // </summary> internal static TypeInfo Create(md.TypeUsage type, TypeInfo superTypeInfo, ExplicitDiscriminatorMap discriminatorMap) { TypeInfo result; if (superTypeInfo == null) { result = new RootTypeInfo(type, discriminatorMap); } else { result = new TypeInfo(type, superTypeInfo); } return(result); }
internal TypeInfo GetTypeInfo(md.TypeUsage type) { if (!TypeUtils.IsStructuredType(type)) { return(null); } TypeInfo typeInfo = null; if (!m_typeInfoMap.TryGetValue(type, out typeInfo)) { PlanCompiler.Assert( !TypeUtils.IsStructuredType(type) || !m_typeInfoMapPopulated, "cannot find typeInfo for type " + type); } return(typeInfo); }
// <summary> // "Explode" a type. (ie) produce a flat record type with one property for each // scalar property (top-level or nested) of the original type. // Really deals with structured types, but also // peels off collection wrappers // </summary> // <param name="type"> the type to explode </param> // <returns> the typeinfo for this type (with the explosion) </returns> private TypeInfo ExplodeType(md.TypeUsage type) { if (TypeUtils.IsStructuredType(type)) { var typeInfo = GetTypeInfo(type); ExplodeType(typeInfo); return(typeInfo); } if (TypeUtils.IsCollectionType(type)) { var elementType = TypeHelpers.GetEdmType <md.CollectionType>(type).TypeUsage; ExplodeType(elementType); return(null); } return(null); }
private void Process( Command itree, HashSet <md.TypeUsage> referencedTypes, HashSet <md.EntitySet> referencedEntitySets, HashSet <md.EntityType> freeFloatingEntityConstructorTypes, Dictionary <md.EntitySetBase, DiscriminatorMapInfo> discriminatorMaps, RelPropertyHelper relPropertyHelper) { PlanCompiler.Assert(null != itree, "null itree?"); m_stringType = itree.StringType; m_intType = itree.IntegerType; m_relPropertyHelper = relPropertyHelper; ProcessEntitySets(referencedEntitySets, freeFloatingEntityConstructorTypes); ProcessDiscriminatorMaps(discriminatorMaps); ProcessTypes(referencedTypes); }
// <summary> // Create a TypeInfo (if necessary) for the type, and add it to the TypeInfo map // </summary> // <param name="type"> the type to process </param> private void CreateTypeInfoForType(md.TypeUsage type) { // // peel off all collection wrappers // while (TypeUtils.IsCollectionType(type)) { type = TypeHelpers.GetEdmType <md.CollectionType>(type).TypeUsage; } // Only add "structured" types if (TypeUtils.IsStructuredType(type)) { // check for discriminator map... ExplicitDiscriminatorMap discriminatorMap; TryGetDiscriminatorMap(type.EdmType, out discriminatorMap); CreateTypeInfoForStructuredType(type, discriminatorMap); } }
// <summary> // Create a column map for a structural column - ref/complextype/entity/record // </summary> // <param name="type"> Type info for the type </param> // <param name="name"> column name </param> private ColumnMap CreateStructuralColumnMap(md.TypeUsage type, string name) { // Get our augmented type information for this type var typeInfo = m_typeInfo.GetTypeInfo(type); // records? if (md.TypeSemantics.IsRowType(type)) { return(CreateRecordColumnMap(typeInfo, name)); } // ref? if (md.TypeSemantics.IsReferenceType(type)) { return(CreateRefColumnMap(typeInfo, name)); } // polymorphic type? if (typeInfo.HasTypeIdProperty) { return(CreatePolymorphicColumnMap(typeInfo, name)); } // process complex/entity types appropriately if (md.TypeSemantics.IsComplexType(type)) { return(CreateComplexTypeColumnMap(typeInfo, name, null, null, null)); } if (md.TypeSemantics.IsEntityType(type)) { return(CreateEntityColumnMap(typeInfo, name, null, null, null, true)); } // Anything else is not supported (this currently includes relationship types) throw new NotSupportedException(type.Identity); }
private static EdmFunction ConvertToFunction( System.Data.Entity.Core.SchemaObjectModel.Function somFunction, DbProviderManifest providerManifest, Converter.ConversionCache convertedItemCache, EntityContainer functionImportEntityContainer, Dictionary <SchemaElement, GlobalItem> newGlobalItems) { GlobalItem globalItem = (GlobalItem)null; if (!somFunction.IsFunctionImport && newGlobalItems.TryGetValue((SchemaElement)somFunction, out globalItem)) { return((EdmFunction)globalItem); } bool areConvertingForProviderManifest = somFunction.Schema.DataModel == SchemaDataModelOption.ProviderManifestModel; List <FunctionParameter> functionParameterList1 = new List <FunctionParameter>(); if (somFunction.ReturnTypeList != null) { int num = 0; foreach (ReturnType returnType in (IEnumerable <ReturnType>)somFunction.ReturnTypeList) { TypeUsage functionTypeUsage = Converter.GetFunctionTypeUsage(somFunction is ModelFunction, somFunction, (FacetEnabledSchemaElement)returnType, providerManifest, areConvertingForProviderManifest, returnType.Type, returnType.CollectionKind, returnType.IsRefType, convertedItemCache, newGlobalItems); if (functionTypeUsage == null) { return((EdmFunction)null); } string str = num == 0 ? string.Empty : num.ToString((IFormatProvider)CultureInfo.InvariantCulture); ++num; FunctionParameter functionParameter = new FunctionParameter("ReturnType" + str, functionTypeUsage, ParameterMode.ReturnValue); Converter.AddOtherContent((SchemaElement)returnType, (MetadataItem)functionParameter); functionParameterList1.Add(functionParameter); } } else if (somFunction.Type != null) { TypeUsage functionTypeUsage = Converter.GetFunctionTypeUsage(somFunction is ModelFunction, somFunction, (FacetEnabledSchemaElement)null, providerManifest, areConvertingForProviderManifest, somFunction.Type, somFunction.CollectionKind, somFunction.IsReturnAttributeReftype, convertedItemCache, newGlobalItems); if (functionTypeUsage == null) { return((EdmFunction)null); } functionParameterList1.Add(new FunctionParameter("ReturnType", functionTypeUsage, ParameterMode.ReturnValue)); } EntitySet[] entitySetArray = (EntitySet[])null; string name; if (somFunction.IsFunctionImport) { FunctionImportElement functionImportElement = (FunctionImportElement)somFunction; name = functionImportElement.Container.Name; if (functionImportElement.EntitySet != null) { EntityContainer container = functionImportEntityContainer; entitySetArray = new EntitySet[1] { Converter.GetEntitySet(functionImportElement.EntitySet, container) }; } else if (functionImportElement.ReturnTypeList != null) { EntityContainer entityContainer = functionImportEntityContainer; entitySetArray = functionImportElement.ReturnTypeList.Select <ReturnType, EntitySet>((Func <ReturnType, EntitySet>)(returnType => { if (returnType.EntitySet == null) { return((EntitySet)null); } return(Converter.GetEntitySet(returnType.EntitySet, functionImportEntityContainer)); })).ToArray <EntitySet>(); } } else { name = somFunction.Namespace; } List <FunctionParameter> functionParameterList2 = new List <FunctionParameter>(); foreach (Parameter parameter in somFunction.Parameters) { TypeUsage functionTypeUsage = Converter.GetFunctionTypeUsage(somFunction is ModelFunction, somFunction, (FacetEnabledSchemaElement)parameter, providerManifest, areConvertingForProviderManifest, parameter.Type, parameter.CollectionKind, parameter.IsRefType, convertedItemCache, newGlobalItems); if (functionTypeUsage == null) { return((EdmFunction)null); } FunctionParameter functionParameter = new FunctionParameter(parameter.Name, functionTypeUsage, Converter.GetParameterMode(parameter.ParameterDirection)); Converter.AddOtherContent((SchemaElement)parameter, (MetadataItem)functionParameter); if (parameter.Documentation != null) { functionParameter.Documentation = Converter.ConvertToDocumentation(parameter.Documentation); } functionParameterList2.Add(functionParameter); } EdmFunction edmFunction = new EdmFunction(somFunction.Name, name, Converter.GetDataSpace(providerManifest), new EdmFunctionPayload() { Schema = somFunction.DbSchema, StoreFunctionName = somFunction.StoreFunctionName, CommandText = somFunction.CommandText, EntitySets = (IList <EntitySet>)entitySetArray, IsAggregate = new bool?(somFunction.IsAggregate), IsBuiltIn = new bool?(somFunction.IsBuiltIn), IsNiladic = new bool?(somFunction.IsNiladicFunction), IsComposable = new bool?(somFunction.IsComposable), IsFromProviderManifest = new bool?(areConvertingForProviderManifest), IsFunctionImport = new bool?(somFunction.IsFunctionImport), ReturnParameters = (IList <FunctionParameter>)functionParameterList1.ToArray(), Parameters = (IList <FunctionParameter>)functionParameterList2.ToArray(), ParameterTypeSemantics = new ParameterTypeSemantics?(somFunction.ParameterTypeSemantics) }); if (!somFunction.IsFunctionImport) { newGlobalItems.Add((SchemaElement)somFunction, (GlobalItem)edmFunction); } if (somFunction.Documentation != null) { edmFunction.Documentation = Converter.ConvertToDocumentation(somFunction.Documentation); } Converter.AddOtherContent((SchemaElement)somFunction, (MetadataItem)edmFunction); return(edmFunction); }
internal static TypeUsage Create(EdmType edmType, FacetValues values) { return(new TypeUsage(edmType, TypeUsage.GetDefaultFacetDescriptionsAndOverrideFacetValues(edmType, values))); }
private static TypeUsage GetFunctionTypeUsage( bool isModelFunction, System.Data.Entity.Core.SchemaObjectModel.Function somFunction, FacetEnabledSchemaElement somParameter, DbProviderManifest providerManifest, bool areConvertingForProviderManifest, System.Data.Entity.Core.SchemaObjectModel.SchemaType type, CollectionKind collectionKind, bool isRefType, Converter.ConversionCache convertedItemCache, Dictionary <SchemaElement, GlobalItem> newGlobalItems) { if (somParameter != null && areConvertingForProviderManifest && somParameter.HasUserDefinedFacets) { return(somParameter.TypeUsage); } if (type == null) { if (isModelFunction && somParameter != null && somParameter is Parameter) { ((Parameter)somParameter).ResolveNestedTypeNames(convertedItemCache, newGlobalItems); return(somParameter.TypeUsage); } if (somParameter == null || !(somParameter is ReturnType)) { return((TypeUsage)null); } ((ReturnType)somParameter).ResolveNestedTypeNames(convertedItemCache, newGlobalItems); return(somParameter.TypeUsage); } EdmType edmType; if (!areConvertingForProviderManifest) { ScalarType scalarType = type as ScalarType; if (scalarType != null) { if (isModelFunction && somParameter != null) { if (somParameter.TypeUsage == null) { somParameter.ValidateAndSetTypeUsage(scalarType); } return(somParameter.TypeUsage); } if (isModelFunction) { ModelFunction modelFunction = somFunction as ModelFunction; if (modelFunction.TypeUsage == null) { modelFunction.ValidateAndSetTypeUsage(scalarType); } return(modelFunction.TypeUsage); } if (somParameter != null && somParameter.HasUserDefinedFacets && somFunction.Schema.DataModel == SchemaDataModelOption.ProviderDataModel) { somParameter.ValidateAndSetTypeUsage(scalarType); return(somParameter.TypeUsage); } edmType = (EdmType)Converter.GetPrimitiveType(scalarType, providerManifest); } else { edmType = (EdmType)Converter.LoadSchemaElement(type, providerManifest, convertedItemCache, newGlobalItems); if (isModelFunction && type is SchemaEnumType) { if (somParameter != null) { somParameter.ValidateAndSetTypeUsage(edmType); return(somParameter.TypeUsage); } if (somFunction != null) { ModelFunction modelFunction = (ModelFunction)somFunction; modelFunction.ValidateAndSetTypeUsage(edmType); return(modelFunction.TypeUsage); } } } } else { edmType = !(type is TypeElement) ? (EdmType)(type as ScalarType).Type : (EdmType)(type as TypeElement).PrimitiveType; } TypeUsage typeUsage; if (collectionKind != CollectionKind.None) { typeUsage = convertedItemCache.GetCollectionTypeUsageWithNullFacets(edmType); } else { EntityType entityType = edmType as EntityType; typeUsage = entityType == null || !isRefType?convertedItemCache.GetTypeUsageWithNullFacets(edmType) : TypeUsage.Create((EdmType) new RefType(entityType)); } return(typeUsage); }
internal void ResolveNavigationProperty(StructuralType declaringType, PropertyInfo propertyInfo) { // EdmScalarPropertyAttribute, EdmComplexPropertyAttribute and EdmRelationshipNavigationPropertyAttribute // are all EdmPropertyAttributes that we need to process. If the current property is not an EdmPropertyAttribute // we will just ignore it and skip to the next property. var relationshipPropertyAttributes = propertyInfo.GetCustomAttributes <EdmRelationshipNavigationPropertyAttribute>(inherit: false); Debug.Assert(relationshipPropertyAttributes.Count() == 1, "There should be exactly one property for every navigation property"); // The only valid return types from navigation properties are: // (1) EntityType // (2) CollectionType containing valid EntityType // If TryGetLoadedType returned false, it could mean that we couldn't validate any part of the type, or it could mean that it's a generic // where the main generic type was validated, but the generic type parameter was not. We can't tell the difference, so just fail // with the same error message in both cases. The user will have to figure out which part of the type is wrong. // We can't just rely on checking for a generic because it can lead to a scenario where we report that the type parameter is invalid // when really it's the main generic type. That is more confusing than reporting the full name and letting the user determine the problem. EdmType propertyType; if (!TryGetLoadedType(propertyInfo.PropertyType, out propertyType) || !(propertyType.BuiltInTypeKind == BuiltInTypeKind.EntityType || propertyType.BuiltInTypeKind == BuiltInTypeKind.CollectionType)) { // Once an error is detected the property does not need to be validated further, just add to the errors // collection and continue with the next property. The failure will cause an exception to be thrown later during validation of all of the types. SessionData.EdmItemErrors.Add( new EdmItemError( Strings.Validator_OSpace_InvalidNavPropReturnType( propertyInfo.Name, propertyInfo.DeclaringType.FullName, propertyInfo.PropertyType.FullName))); return; } // else we have a valid EntityType or CollectionType that contains EntityType. ResolveNonSchemaType enforces that a collection type // must contain an EntityType, and if it doesn't, propertyType will be null here. If propertyType is EntityType or CollectionType we know it is valid // Expecting EdmRelationshipNavigationPropertyAttribute to have AllowMultiple=False, so only look at first element in the attribute array var attribute = (EdmRelationshipNavigationPropertyAttribute)relationshipPropertyAttributes.First(); EdmMember member = null; EdmType type; if (SessionData.TypesInLoading.TryGetValue(attribute.RelationshipNamespaceName + "." + attribute.RelationshipName, out type) && Helper.IsAssociationType(type)) { var relationshipType = (AssociationType)type; if (relationshipType != null) { // The return value of this property has been verified, so create the property now var navigationProperty = new NavigationProperty(propertyInfo.Name, TypeUsage.Create(propertyType)); navigationProperty.RelationshipType = relationshipType; member = navigationProperty; if (relationshipType.Members[0].Name == attribute.TargetRoleName) { navigationProperty.ToEndMember = (RelationshipEndMember)relationshipType.Members[0]; navigationProperty.FromEndMember = (RelationshipEndMember)relationshipType.Members[1]; } else if (relationshipType.Members[1].Name == attribute.TargetRoleName) { navigationProperty.ToEndMember = (RelationshipEndMember)relationshipType.Members[1]; navigationProperty.FromEndMember = (RelationshipEndMember)relationshipType.Members[0]; } else { SessionData.EdmItemErrors.Add( new EdmItemError( Strings.TargetRoleNameInNavigationPropertyNotValid( propertyInfo.Name, propertyInfo.DeclaringType.FullName, attribute.TargetRoleName, attribute.RelationshipName))); member = null; } if (member != null && ((RefType)navigationProperty.FromEndMember.TypeUsage.EdmType).ElementType.ClrType != declaringType.ClrType) { SessionData.EdmItemErrors.Add( new EdmItemError( Strings.NavigationPropertyRelationshipEndTypeMismatch( declaringType.FullName, navigationProperty.Name, relationshipType.FullName, navigationProperty.FromEndMember.Name, ((RefType)navigationProperty.FromEndMember.TypeUsage.EdmType).ElementType.ClrType))); member = null; } } } else { SessionData.EdmItemErrors.Add( new EdmItemError( Strings.RelationshipNameInNavigationPropertyNotValid( propertyInfo.Name, propertyInfo.DeclaringType.FullName, attribute.RelationshipName))); } if (member != null) { declaringType.AddMember(member); } }
internal static bool IsSpatialType(TypeUsage type) { return(type.EdmType.BuiltInTypeKind == BuiltInTypeKind.PrimitiveType && IsSpatialType((PrimitiveType)type.EdmType)); }
internal TypeUsage ShallowCopy(params Facet[] facetValues) { return(TypeUsage.Create(this._edmType, TypeUsage.OverrideFacetValues((IEnumerable <Facet>) this.Facets, (IEnumerable <Facet>)facetValues))); }
public void This_returned_for_CSPace_type() { var typeUsage = TypeUsage.CreateDefaultTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32)); Assert.Same(typeUsage, typeUsage.ModelTypeUsage); }
private static IEnumerable <Facet> OverrideFacetValues( IEnumerable <Facet> facets, FacetValues values) { return(TypeUsage.OverrideFacetValues <Facet>(facets, (Func <Facet, FacetDescription>)(f => f.Description), (Func <Facet, Facet>)(f => f), values)); }
// <summary> // Is this type an enum type? // </summary> // <param name="type"> the current type </param> // <returns> true, if this is an enum type </returns> internal static bool IsEnumerationType(md.TypeUsage type) { return(md.TypeSemantics.IsEnumerationType(type)); }
private void Process( Command itree, HashSet<md.TypeUsage> referencedTypes, HashSet<md.EntitySet> referencedEntitySets, HashSet<md.EntityType> freeFloatingEntityConstructorTypes, Dictionary<md.EntitySetBase, DiscriminatorMapInfo> discriminatorMaps, RelPropertyHelper relPropertyHelper) { PlanCompiler.Assert(null != itree, "null itree?"); m_stringType = itree.StringType; m_intType = itree.IntegerType; m_relPropertyHelper = relPropertyHelper; ProcessEntitySets(referencedEntitySets, freeFloatingEntityConstructorTypes); ProcessDiscriminatorMaps(discriminatorMaps); ProcessTypes(referencedTypes); }
static MetadataItem() { //////////////////////////////////////////////////////////////////////////////////////////////// // Bootstrapping the builtin types //////////////////////////////////////////////////////////////////////////////////////////////// _builtInTypes[(int)BuiltInTypeKind.AssociationEndMember] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.AssociationSet] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.AssociationSetEnd] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.AssociationType] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.AssociationType] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.CollectionKind] = new EnumType(); _builtInTypes[(int)BuiltInTypeKind.CollectionType] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.ComplexType] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.Documentation] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.OperationAction] = new EnumType(); _builtInTypes[(int)BuiltInTypeKind.EdmType] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.EntityContainer] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.EntitySet] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.EntityType] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.EntitySetBase] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.EntityTypeBase] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.EnumType] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.EnumMember] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.Facet] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.EdmFunction] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.FunctionParameter] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.GlobalItem] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.MetadataProperty] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.NavigationProperty] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.MetadataItem] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.EdmMember] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.ParameterMode] = new EnumType(); _builtInTypes[(int)BuiltInTypeKind.PrimitiveType] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.PrimitiveTypeKind] = new EnumType(); _builtInTypes[(int)BuiltInTypeKind.EdmProperty] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.ProviderManifest] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.ReferentialConstraint] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.RefType] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.RelationshipEndMember] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.RelationshipMultiplicity] = new EnumType(); _builtInTypes[(int)BuiltInTypeKind.RelationshipSet] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.RelationshipType] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.RowType] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.SimpleType] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.StructuralType] = new ComplexType(); _builtInTypes[(int)BuiltInTypeKind.TypeUsage] = new ComplexType(); //////////////////////////////////////////////////////////////////////////////////////////////// // Initialize item attributes for all the built-in complex types //////////////////////////////////////////////////////////////////////////////////////////////// InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.MetadataItem), EdmConstants.ItemType, false /*isAbstract*/, null); // populate the attributes for item attributes InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.MetadataProperty), EdmConstants.ItemAttribute, true /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.MetadataItem)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.GlobalItem), EdmConstants.GlobalItem, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.MetadataItem)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.TypeUsage), EdmConstants.TypeUsage, false, /*isAbstract*/ (ComplexType)GetBuiltInType(BuiltInTypeKind.MetadataItem)); //populate the attributes for the edm type InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.EdmType), EdmConstants.EdmType, true, /*isAbstract*/ (ComplexType)GetBuiltInType(BuiltInTypeKind.GlobalItem)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.SimpleType), EdmConstants.SimpleType, true /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.EdmType)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.EnumType), EdmConstants.EnumerationType, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.SimpleType)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.PrimitiveType), EdmConstants.PrimitiveType, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.SimpleType)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.CollectionType), EdmConstants.CollectionType, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.EdmType)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.RefType), EdmConstants.RefType, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.EdmType)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.EdmMember), EdmConstants.Member, true /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.MetadataItem)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.EdmProperty), EdmConstants.Property, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.EdmMember)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.NavigationProperty), EdmConstants.NavigationProperty, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.EdmMember)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.ProviderManifest), EdmConstants.ProviderManifest, true /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.MetadataItem)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.RelationshipEndMember), EdmConstants.RelationshipEnd, true /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.EdmMember)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.AssociationEndMember), EdmConstants.AssociationEnd, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.RelationshipEndMember)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.EnumMember), EdmConstants.EnumerationMember, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.MetadataItem)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.ReferentialConstraint), EdmConstants.ReferentialConstraint, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.MetadataItem)); // Structural Type hierarchy InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.StructuralType), EdmConstants.StructuralType, true /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.EdmType)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.RowType), EdmConstants.RowType, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.StructuralType)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.ComplexType), EdmConstants.ComplexType, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.StructuralType)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.EntityTypeBase), EdmConstants.ElementType, true /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.StructuralType)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.EntityType), EdmConstants.EntityType, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.EntityTypeBase)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.RelationshipType), EdmConstants.RelationshipType, true /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.EntityTypeBase)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.AssociationType), EdmConstants.AssociationType, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.RelationshipType)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.Facet), EdmConstants.Facet, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.MetadataItem)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.EntityContainer), EdmConstants.EntityContainerType, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.GlobalItem)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.EntitySetBase), EdmConstants.BaseEntitySetType, true /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.MetadataItem)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.EntitySet), EdmConstants.EntitySetType, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.EntitySetBase)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.RelationshipSet), EdmConstants.RelationshipSet, true /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.EntitySetBase)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.AssociationSet), EdmConstants.AssociationSetType, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.RelationshipSet)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.AssociationSetEnd), EdmConstants.AssociationSetEndType, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.MetadataItem)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.FunctionParameter), EdmConstants.FunctionParameter, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.MetadataItem)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.EdmFunction), EdmConstants.Function, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.EdmType)); InitializeBuiltInTypes( (ComplexType)GetBuiltInType(BuiltInTypeKind.Documentation), EdmConstants.Documentation, false /*isAbstract*/, (ComplexType)GetBuiltInType(BuiltInTypeKind.MetadataItem)); //////////////////////////////////////////////////////////////////////////////////////////////// // Initialize item attributes for all the built-in enum types //////////////////////////////////////////////////////////////////////////////////////////////// InitializeEnumType( BuiltInTypeKind.OperationAction, EdmConstants.DeleteAction, new[] { EdmConstants.None, EdmConstants.Cascade, EdmConstants.Restrict }); InitializeEnumType( BuiltInTypeKind.RelationshipMultiplicity, EdmConstants.RelationshipMultiplicity, new[] { EdmConstants.One, EdmConstants.ZeroToOne, EdmConstants.Many }); InitializeEnumType( BuiltInTypeKind.ParameterMode, EdmConstants.ParameterMode, new[] { EdmConstants.In, EdmConstants.Out, EdmConstants.InOut }); InitializeEnumType( BuiltInTypeKind.CollectionKind, EdmConstants.CollectionKind, new[] { EdmConstants.NoneCollectionKind, EdmConstants.ListCollectionKind, EdmConstants.BagCollectionKind }); InitializeEnumType( BuiltInTypeKind.PrimitiveTypeKind, EdmConstants.PrimitiveTypeKind, Enum.GetNames(typeof(PrimitiveTypeKind))); //////////////////////////////////////////////////////////////////////////////////////////////// // Bootstrapping the general facet descriptions //////////////////////////////////////////////////////////////////////////////////////////////// // Other type non-specific facets var generalFacetDescriptions = new FacetDescription[2]; _nullableFacetDescription = new FacetDescription( DbProviderManifest.NullableFacetName, EdmProviderManifest.GetPrimitiveType(PrimitiveTypeKind.Boolean), null, null, true); generalFacetDescriptions[0] = (_nullableFacetDescription); _defaultValueFacetDescription = new FacetDescription( DbProviderManifest.DefaultValueFacetName, GetBuiltInType(BuiltInTypeKind.EdmType), null, null, null); generalFacetDescriptions[1] = (_defaultValueFacetDescription); _generalFacetDescriptions = Array.AsReadOnly(generalFacetDescriptions); _collectionKindFacetDescription = new FacetDescription( XmlConstants.CollectionKind, GetBuiltInType(BuiltInTypeKind.EnumType), null, null, null); //////////////////////////////////////////////////////////////////////////////////////////////// // Add properties for the built-in complex types //////////////////////////////////////////////////////////////////////////////////////////////// var stringTypeUsage = TypeUsage.Create(EdmProviderManifest.GetPrimitiveType(PrimitiveTypeKind.String)); var booleanTypeUsage = TypeUsage.Create(EdmProviderManifest.GetPrimitiveType(PrimitiveTypeKind.Boolean)); var edmTypeUsage = TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.EdmType)); var typeUsageTypeUsage = TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.TypeUsage)); var complexTypeUsage = TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.ComplexType)); // populate the attributes for item attributes AddBuiltInTypeProperties( BuiltInTypeKind.MetadataProperty, new[] { new EdmProperty(EdmConstants.Name, stringTypeUsage), new EdmProperty(EdmConstants.TypeUsage, typeUsageTypeUsage), new EdmProperty(EdmConstants.Value, complexTypeUsage) }); AddBuiltInTypeProperties( BuiltInTypeKind.MetadataItem, new[] { new EdmProperty( EdmConstants.ItemAttributes, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.MetadataProperty).GetCollectionType())), new EdmProperty(EdmConstants.Documentation, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.Documentation))) }); AddBuiltInTypeProperties( BuiltInTypeKind.TypeUsage, new[] { new EdmProperty(EdmConstants.EdmType, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.EdmType))), new EdmProperty(EdmConstants.Facets, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.Facet))) }); //populate the attributes for the edm type AddBuiltInTypeProperties( BuiltInTypeKind.EdmType, new[] { new EdmProperty(EdmConstants.Name, stringTypeUsage), new EdmProperty(EdmConstants.Namespace, stringTypeUsage), new EdmProperty(EdmConstants.Abstract, booleanTypeUsage), new EdmProperty(EdmConstants.Sealed, booleanTypeUsage), new EdmProperty(EdmConstants.BaseType, complexTypeUsage) }); AddBuiltInTypeProperties( BuiltInTypeKind.EnumType, new[] { new EdmProperty(EdmConstants.EnumMembers, stringTypeUsage) }); AddBuiltInTypeProperties( BuiltInTypeKind.CollectionType, new[] { new EdmProperty(EdmConstants.TypeUsage, typeUsageTypeUsage) }); AddBuiltInTypeProperties( BuiltInTypeKind.RefType, new[] { new EdmProperty(EdmConstants.EntityType, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.EntityType))) }); AddBuiltInTypeProperties( BuiltInTypeKind.EdmMember, new[] { new EdmProperty(EdmConstants.Name, stringTypeUsage), new EdmProperty(EdmConstants.TypeUsage, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.TypeUsage))) }); AddBuiltInTypeProperties( BuiltInTypeKind.EdmProperty, new[] { new EdmProperty(EdmConstants.Nullable, stringTypeUsage), new EdmProperty(EdmConstants.DefaultValue, complexTypeUsage) }); AddBuiltInTypeProperties( BuiltInTypeKind.NavigationProperty, new[] { new EdmProperty(EdmConstants.RelationshipTypeName, stringTypeUsage), new EdmProperty(EdmConstants.ToEndMemberName, stringTypeUsage) }); AddBuiltInTypeProperties( BuiltInTypeKind.RelationshipEndMember, new[] { new EdmProperty(EdmConstants.OperationBehaviors, complexTypeUsage), new EdmProperty(EdmConstants.RelationshipMultiplicity, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.EnumType))) }); AddBuiltInTypeProperties( BuiltInTypeKind.EnumMember, new[] { new EdmProperty(EdmConstants.Name, stringTypeUsage) }); AddBuiltInTypeProperties( BuiltInTypeKind.ReferentialConstraint, new[] { new EdmProperty(EdmConstants.ToRole, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.RelationshipEndMember))), new EdmProperty(EdmConstants.FromRole, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.RelationshipEndMember))), new EdmProperty( EdmConstants.ToProperties, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.EdmProperty).GetCollectionType())), new EdmProperty( EdmConstants.FromProperties, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.EdmProperty).GetCollectionType())) }); // Structural Type hierarchy AddBuiltInTypeProperties( BuiltInTypeKind.StructuralType, new[] { new EdmProperty(EdmConstants.Members, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.EdmMember))) }); AddBuiltInTypeProperties( BuiltInTypeKind.EntityTypeBase, new[] { new EdmProperty(EdmConstants.KeyMembers, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.EdmMember))) }); AddBuiltInTypeProperties( BuiltInTypeKind.Facet, new[] { new EdmProperty(EdmConstants.Name, stringTypeUsage), new EdmProperty(EdmConstants.EdmType, edmTypeUsage), new EdmProperty(EdmConstants.Value, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.EdmType))) }); AddBuiltInTypeProperties( BuiltInTypeKind.EntityContainer, new[] { new EdmProperty(EdmConstants.Name, stringTypeUsage), new EdmProperty(EdmConstants.EntitySets, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.EntitySet))) }); AddBuiltInTypeProperties( BuiltInTypeKind.EntitySetBase, new[] { new EdmProperty(EdmConstants.Name, stringTypeUsage), new EdmProperty(EdmConstants.EntityType, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.EntityType))), new EdmProperty(EdmConstants.Schema, stringTypeUsage), new EdmProperty(EdmConstants.Table, stringTypeUsage) }); AddBuiltInTypeProperties( BuiltInTypeKind.AssociationSet, new[] { new EdmProperty( EdmConstants.AssociationSetEnds, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.AssociationSetEnd).GetCollectionType())) }); AddBuiltInTypeProperties( BuiltInTypeKind.AssociationSetEnd, new[] { new EdmProperty(EdmConstants.Role, stringTypeUsage), new EdmProperty(EdmConstants.EntitySetType, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.EntitySet))) }); AddBuiltInTypeProperties( BuiltInTypeKind.FunctionParameter, new[] { new EdmProperty(EdmConstants.Name, stringTypeUsage), new EdmProperty(EdmConstants.Mode, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.EnumType))), new EdmProperty(EdmConstants.TypeUsage, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.TypeUsage))) }); AddBuiltInTypeProperties( BuiltInTypeKind.EdmFunction, new[] { new EdmProperty(EdmConstants.Name, stringTypeUsage), new EdmProperty(EdmConstants.Namespace, stringTypeUsage), new EdmProperty(EdmConstants.ReturnParameter, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.FunctionParameter))), new EdmProperty( EdmConstants.Parameters, TypeUsage.Create(GetBuiltInType(BuiltInTypeKind.FunctionParameter).GetCollectionType())) }); AddBuiltInTypeProperties( BuiltInTypeKind.Documentation, new[] { new EdmProperty(EdmConstants.Summary, stringTypeUsage), new EdmProperty(EdmConstants.LongDescription, stringTypeUsage) }); // Set all types to be readonly, used SetReadOnly to skip validation method to for (var i = 0; i < _builtInTypes.Length; i++) { _builtInTypes[i].SetReadOnly(); } }
internal CollectionType(EdmType elementType) : this(TypeUsage.Create(elementType)) { DataSpace = elementType.DataSpace; }
private TypeInfo CreateTypeInfoForStructuredType(md.TypeUsage type, ExplicitDiscriminatorMap discriminatorMap) { TypeInfo typeInfo; PlanCompiler.Assert(TypeUtils.IsStructuredType(type), "expected structured type. Found " + type); // Return existing entry, if one is available typeInfo = GetTypeInfo(type); if (typeInfo != null) { return(typeInfo); } // Ensure that my supertype has been added to the map. TypeInfo superTypeInfo = null; md.RefType refType; if (type.EdmType.BaseType != null) { superTypeInfo = CreateTypeInfoForStructuredType(md.TypeUsage.Create(type.EdmType.BaseType), discriminatorMap); } // // Handle Ref types also in a similar fashion // else if (TypeHelpers.TryGetEdmType(type, out refType)) { var entityType = refType.ElementType as md.EntityType; if (entityType != null && entityType.BaseType != null) { var baseRefType = TypeHelpers.CreateReferenceTypeUsage(entityType.BaseType as md.EntityType); superTypeInfo = CreateTypeInfoForStructuredType(baseRefType, discriminatorMap); } } // // Add the types of my properties to the TypeInfo map // foreach (md.EdmMember m in TypeHelpers.GetDeclaredStructuralMembers(type)) { CreateTypeInfoForType(m.TypeUsage); } // // Get the types of the rel properties also // { md.EntityTypeBase entityType; if (TypeHelpers.TryGetEdmType(type, out entityType)) { foreach (var p in m_relPropertyHelper.GetDeclaredOnlyRelProperties(entityType)) { CreateTypeInfoForType(p.ToEnd.TypeUsage); } } } // Now add myself to the map typeInfo = TypeInfo.Create(type, superTypeInfo, discriminatorMap); m_typeInfoMap.Add(type, typeInfo); return(typeInfo); }
private static IEnumerable <Facet> GetDefaultFacetDescriptionsAndOverrideFacetValues( EdmType type, FacetValues values) { return(TypeUsage.OverrideFacetValues <FacetDescription>(type.GetAssociatedFacetDescriptions(), (Func <FacetDescription, FacetDescription>)(fd => fd), (Func <FacetDescription, Facet>)(fd => fd.DefaultValueFacet), values)); }
public void Create_throws_argument_exception_when_called_with_invalid_arguments() { var source = new EntityType("Source", "Namespace", DataSpace.CSpace); var target = new EntityType("Target", "Namespace", DataSpace.CSpace); var sourceEnd = new AssociationEndMember("SourceEnd", source); var targetEnd = new AssociationEndMember("TargetEnd", target); var constraint = new ReferentialConstraint( sourceEnd, targetEnd, new[] { new EdmProperty("SourceProperty") }, new[] { new EdmProperty("TargetProperty") }); var metadataProperty = new MetadataProperty( "MetadataProperty", TypeUsage.CreateDefaultTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)), "value"); Assert.Throws <ArgumentException>( () => AssociationType.Create( null, "Namespace", true, DataSpace.CSpace, sourceEnd, targetEnd, constraint, new[] { metadataProperty })); Assert.Throws <ArgumentException>( () => AssociationType.Create( String.Empty, "Namespace", true, DataSpace.CSpace, sourceEnd, targetEnd, constraint, new[] { metadataProperty })); Assert.Throws <ArgumentException>( () => AssociationType.Create( "AssociationType", null, true, DataSpace.CSpace, sourceEnd, targetEnd, constraint, new[] { metadataProperty })); Assert.Throws <ArgumentException>( () => AssociationType.Create( "AssociationType", String.Empty, true, DataSpace.CSpace, sourceEnd, targetEnd, constraint, new[] { metadataProperty })); }
private static Dictionary <Var, md.EdmProperty> BuildOutputVarMap(PhysicalProjectOp projectOp, md.TypeUsage outputType) { var outputVarMap = new Dictionary <Var, md.EdmProperty>(); PlanCompiler.Assert(md.TypeSemantics.IsRowType(outputType), "PhysicalProjectOp result type is not a RowType?"); IEnumerator <md.EdmProperty> propertyEnumerator = TypeHelpers.GetEdmType <md.RowType>(outputType).Properties.GetEnumerator(); IEnumerator <Var> varEnumerator = projectOp.Outputs.GetEnumerator(); while (true) { var foundProp = propertyEnumerator.MoveNext(); var foundVar = varEnumerator.MoveNext(); if (foundProp != foundVar) { throw EntityUtil.InternalError(EntityUtil.InternalErrorCode.ColumnCountMismatch, 1, null); } if (!foundProp) { break; } outputVarMap[varEnumerator.Current] = propertyEnumerator.Current; } return(outputVarMap); }
/// <summary> /// Gets a type with the given name in the target space. /// </summary> /// <param name="fullName"> full name of the type </param> /// <param name="ignoreCase"> true for case-insensitive lookup </param> /// <param name="typeUsage"> TypeUsage for the type </param> /// <returns> returns true if a match was found, otherwise false </returns> internal abstract bool TryGetTypeByName(string fullName, bool ignoreCase, out TypeUsage typeUsage);
// <summary> // Create a new collection type based on the supplied element type // </summary> // <param name="elementType"> element type of the collection </param> // <returns> the new collection type </returns> internal static md.TypeUsage CreateCollectionType(md.TypeUsage elementType) { return(TypeHelpers.CreateCollectionTypeUsage(elementType)); }
/// <summary> /// Creates a <see cref="T:System.Data.Entity.Core.Metadata.Edm.TypeUsage" /> object with the specified conceptual model type. /// </summary> /// <returns> /// A <see cref="T:System.Data.Entity.Core.Metadata.Edm.TypeUsage" /> object with the default facet values for the specified /// <see cref="T:System.Data.Entity.Core.Metadata.Edm.EdmType" /> /// . /// </returns> /// <param name="edmType"> /// A <see cref="T:System.Data.Entity.Core.Metadata.Edm.EdmType" /> for which the /// <see cref="T:System.Data.Entity.Core.Metadata.Edm.TypeUsage" /> /// object is created. /// </param> public static TypeUsage CreateDefaultTypeUsage(EdmType edmType) { Check.NotNull <EdmType>(edmType, nameof(edmType)); return(TypeUsage.Create(edmType)); }