internal static void UpdateFunctionImportParameters(
            CommandProcessorContext cpc, FunctionImport fi, IEnumerable <ParameterDefinition> parameterDefinitions)
        {
            DeleteAllParameters(cpc, fi);

            if (parameterDefinitions != null)
            {
                foreach (var definition in parameterDefinitions)
                {
                    var conceptualFunctionParam = new Parameter(fi, null);
                    conceptualFunctionParam.LocalName.Value = definition.Name;
                    conceptualFunctionParam.Mode.Value      = definition.Mode;
                    conceptualFunctionParam.Type.Value      = definition.Type;

                    fi.AddParameter(conceptualFunctionParam);
                    XmlModelHelper.NormalizeAndResolve(conceptualFunctionParam);
                }
            }
        }
        internal static void UpdateFunctionImportParameters(CommandProcessorContext cpc, FunctionImport fi, Function function)
        {
            DeleteAllParameters(cpc, fi);

            if (function != null &&
                function.Parameters().Count > 0)
            {
                var storeTypeNameToStoreTypeMap = function.EntityModel.StoreTypeNameToStoreTypeMap;
                Debug.Assert(
                    storeTypeNameToStoreTypeMap != null, "StoreTypeName to StoreType map should not be null. Not updating function import");
                if (storeTypeNameToStoreTypeMap != null)
                {
                    IDictionary <string, string> storeToEdmPrimitiveMap = storeTypeNameToStoreTypeMap.ToDictionary(
                        kvp => kvp.Key, kvp => kvp.Value.GetEdmPrimitiveType().Name);

                    // Parameter EFElement conveniently can be used in both the C-Side and S-Side.
                    foreach (var storageFunctionParam in function.Parameters())
                    {
                        var conceptualFunctionParam = new Parameter(fi, null);

                        conceptualFunctionParam.LocalName.Value = storageFunctionParam.LocalName.Value;
                        conceptualFunctionParam.Mode.Value      = storageFunctionParam.Mode.Value;

                        string conceptualFunctionParamValue;
                        if (storeToEdmPrimitiveMap.TryGetValue(storageFunctionParam.Type.Value, out conceptualFunctionParamValue))
                        {
                            conceptualFunctionParam.Type.Value = conceptualFunctionParamValue;
                        }
                        else
                        {
                            conceptualFunctionParam.Type.Value = storageFunctionParam.Type.Value;
                        }

                        fi.AddParameter(conceptualFunctionParam);
                        XmlModelHelper.NormalizeAndResolve(conceptualFunctionParam);
                    }
                }
            }
        }
        internal static void UpdateFunctionImportParameters(CommandProcessorContext cpc, FunctionImport fi, Function function)
        {
            DeleteAllParameters(cpc, fi);

            if (function != null
                && function.Parameters().Count > 0)
            {
                var storeTypeNameToStoreTypeMap = function.EntityModel.StoreTypeNameToStoreTypeMap;
                Debug.Assert(
                    storeTypeNameToStoreTypeMap != null, "StoreTypeName to StoreType map should not be null. Not updating function import");
                if (storeTypeNameToStoreTypeMap != null)
                {
                    IDictionary<string, string> storeToEdmPrimitiveMap = storeTypeNameToStoreTypeMap.ToDictionary(
                        kvp => kvp.Key, kvp => kvp.Value.GetEdmPrimitiveType().Name);

                    // Parameter EFElement conveniently can be used in both the C-Side and S-Side.
                    foreach (var storageFunctionParam in function.Parameters())
                    {
                        var conceptualFunctionParam = new Parameter(fi, null);

                        conceptualFunctionParam.LocalName.Value = storageFunctionParam.LocalName.Value;
                        conceptualFunctionParam.Mode.Value = storageFunctionParam.Mode.Value;

                        string conceptualFunctionParamValue;
                        if (storeToEdmPrimitiveMap.TryGetValue(storageFunctionParam.Type.Value, out conceptualFunctionParamValue))
                        {
                            conceptualFunctionParam.Type.Value = conceptualFunctionParamValue;
                        }
                        else
                        {
                            conceptualFunctionParam.Type.Value = storageFunctionParam.Type.Value;
                        }

                        fi.AddParameter(conceptualFunctionParam);
                        XmlModelHelper.NormalizeAndResolve(conceptualFunctionParam);
                    }
                }
            }
        }
        internal static void UpdateFunctionImportParameters(
            CommandProcessorContext cpc, FunctionImport fi, IEnumerable<ParameterDefinition> parameterDefinitions)
        {
            DeleteAllParameters(cpc, fi);

            if (parameterDefinitions != null)
            {
                foreach (var definition in parameterDefinitions)
                {
                    var conceptualFunctionParam = new Parameter(fi, null);
                    conceptualFunctionParam.LocalName.Value = definition.Name;
                    conceptualFunctionParam.Mode.Value = definition.Mode;
                    conceptualFunctionParam.Type.Value = definition.Type;

                    fi.AddParameter(conceptualFunctionParam);
                    XmlModelHelper.NormalizeAndResolve(conceptualFunctionParam);
                }
            }
        }