// <summary>
        // Search for a Mapping metadata with the specified type key.
        // </summary>
        internal virtual MappingBase GetMap(GlobalItem item)
        {
            DebugCheck.NotNull(item);

            //will only be implemented by Mapping Item Collections
            throw Error.NotSupported();
        }
        /// <summary>
        /// Search for a Mapping metadata with the specified type key.
        /// </summary>
        /// <param name="item"></param>
        internal virtual Map GetMap(GlobalItem item)
        {
            Contract.Requires(item != null);

            //will only be implemented by Mapping Item Collections
            throw Error.NotSupported();
        }
Esempio n. 3
0
 private void ValidateSpace(GlobalItem item, string parameterName)
 {
     if (item.DataSpace != _dataSpace)
     {
         throw new ArgumentException(Strings.EdmModel_AddItem_NonMatchingNamespace, parameterName);
     }
 }
        private bool ContainsMap(GlobalItem cspaceItem, out ObjectTypeMapping map)
        {
            Debug.Assert(cspaceItem.DataSpace == DataSpace.CSpace, "ContainsMap: It must be a CSpace item");
            int index;
            if (cdmTypeIndexes.TryGetValue(cspaceItem.Identity, out index))
            {
                map = (ObjectTypeMapping)this[index];
                return true;
            }

            map = null;
            return false;
        }
        /// <summary>
        /// Search for a Mapping metadata with the specified type key.
        /// </summary>
        /// <param name="item"></param>
        /// <param name="map"></param>
        /// <returns>Returns false if no match found.</returns>
        internal override bool TryGetMap(GlobalItem item, out Map map)
        {
            if (item == null)
            {
                map = null;
                return false;
            }

            var typeSpace = item.DataSpace;

            //For transient types just create a map on fly and return
            var edmType = item as EdmType;
            if (edmType != null)
            {
                if (Helper.IsTransientType(edmType))
                {
                    map = GetOCMapForTransientType(edmType, typeSpace);
                    if (map != null)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            return TryGetMap(item.Identity, typeSpace, out map);
        }
 /// <summary>
 /// Search for a Mapping metadata with the specified type key.
 /// </summary>
 /// <param name="item"></param>
 internal override Map GetMap(GlobalItem item)
 {
     Map map;
     if (!TryGetMap(item, out map))
     {
         throw new InvalidOperationException(Strings.Mapping_Object_InvalidType(item.Identity));
     }
     return map;
 }
Esempio n. 7
0
 internal static bool IsEdmFunction(GlobalItem item)
 {
     return(BuiltInTypeKind.EdmFunction == item.BuiltInTypeKind);
 }
Esempio n. 8
0
 internal static bool IsEntityContainer(GlobalItem item)
 {
     return(BuiltInTypeKind.EntityContainer == item.BuiltInTypeKind);
 }
Esempio n. 9
0
 internal static bool IsRowType(GlobalItem item)
 {
     return(BuiltInTypeKind.RowType == item.BuiltInTypeKind);
 }
Esempio n. 10
0
 internal static bool IsCollectionType(GlobalItem item)
 {
     return(BuiltInTypeKind.CollectionType == item.BuiltInTypeKind);
 }
 // <summary>
 // Search for a Mapping metadata with the specified type key.
 // </summary>
 // <returns> Returns false if no match found. </returns>
 internal override bool TryGetMap(GlobalItem item, out MappingBase map)
 {
     if (item == null)
     {
         map = null;
         return false;
     }
     var typeSpace = item.DataSpace;
     if (typeSpace != DataSpace.CSpace)
     {
         map = null;
         return false;
     }
     return TryGetMap(item.Identity, typeSpace, out map);
 }
 // <summary>
 // Search for a Mapping metadata with the specified type key.
 // </summary>
 internal override MappingBase GetMap(GlobalItem item)
 {
     var typeSpace = item.DataSpace;
     if (typeSpace != DataSpace.CSpace)
     {
         throw new InvalidOperationException(Strings.Mapping_Storage_InvalidSpace(typeSpace));
     }
     return GetMap(item.Identity, typeSpace);
 }
 // <summary>
 // Search for a Mapping metadata with the specified type key.
 // </summary>
 // <returns> Returns false if no match found. </returns>
 internal virtual bool TryGetMap(GlobalItem item, out MappingBase map)
 {
     //will only be implemented by Mapping Item Collections
     throw Error.NotSupported();
 }
        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);
        }
Esempio n. 15
0
 private void ValidateSpace(GlobalItem item, string parameterName)
 {
     if (item.DataSpace != _dataSpace)
     {
         throw new ArgumentException(Strings.EdmModel_AddItem_NonMatchingNamespace, parameterName);
     }
 }