private static void AddProcedures(this IEdmModel model, IEnumerable<ProcedureConfiguration> configurations, EdmEntityContainer container, Dictionary<Type, IEdmStructuredType> edmTypeMap, Dictionary<string, EdmEntitySet> edmEntitySetMap)
        {
            foreach (ProcedureConfiguration procedure in configurations)
            {
                switch (procedure.Kind)
                {
                    case ProcedureKind.Action:
                        ActionConfiguration action = procedure as ActionConfiguration;
                        IEdmTypeReference returnReference = GetEdmTypeReference(edmTypeMap, action.ReturnType, nullable: true);
                        IEdmExpression expression = GetEdmEntitySetExpression(edmEntitySetMap, action);

                        EdmFunctionImport functionImport = new EdmFunctionImport(container, action.Name, returnReference, expression, action.IsSideEffecting, action.IsComposable, action.IsBindable);
                        if (action.IsBindable)
                        {
                            model.SetIsAlwaysBindable(functionImport, action.IsAlwaysBindable);
                            if (action.BindingParameter.TypeConfiguration.Kind == EdmTypeKind.Entity)
                            {
                                Func<EntityInstanceContext, Uri> actionFactory = action.GetActionLink();
                                if (actionFactory != null)
                                {
                                    model.SetAnnotationValue<ActionLinkBuilder>(functionImport, new ActionLinkBuilder(actionFactory));
                                }
                            }
                        }

                        foreach (ParameterConfiguration parameter in action.Parameters)
                        {
                            // TODO: http://aspnetwebstack.codeplex.com/workitem/417
                            bool isParameterOptional = EdmLibHelpers.IsNullable(parameter.TypeConfiguration.ClrType);
                            IEdmTypeReference parameterTypeReference = GetEdmTypeReference(edmTypeMap, parameter.TypeConfiguration, nullable: isParameterOptional);
                            EdmFunctionParameter functionParameter = new EdmFunctionParameter(functionImport, parameter.Name, parameterTypeReference, EdmFunctionParameterMode.In);
                            functionImport.AddParameter(functionParameter);
                        }
                        container.AddElement(functionImport);
                        break;

                    case ProcedureKind.Function:
                        Contract.Assert(false, "Functions are not supported.");
                        break;

                    case ProcedureKind.ServiceOperation:
                        Contract.Assert(false, "ServiceOperations are not supported.");
                        break;
                }
            }
        }
        private static void AddProcedures(this EdmEntityContainer container, IEnumerable<ProcedureConfiguration> configurations, Dictionary<string, IEdmStructuredType> edmTypeMap, Dictionary<string, EdmEntitySet> edmEntitySetMap)
        {
            foreach (ProcedureConfiguration procedure in configurations)
            {
                switch (procedure.Kind)
                {
                    case ProcedureKind.Action:
                        ActionConfiguration action = procedure as ActionConfiguration;
                        IEdmTypeReference returnReference = GetEdmTypeReference(edmTypeMap, action.ReturnType, nullable: true);
                        IEdmExpression expression = GetEdmEntitySetExpression(edmEntitySetMap, action);

                        EdmFunctionImport functionImport = new EdmFunctionImport(container, action.Name, returnReference, expression, action.IsSideEffecting, action.IsComposable, action.IsBindable);
                        foreach (ParameterConfiguration parameter in action.Parameters)
                        {
                            // TODO: http://aspnetwebstack.codeplex.com/workitem/417
                            IEdmTypeReference parameterTypeReference = GetEdmTypeReference(edmTypeMap, parameter.TypeConfiguration, nullable: true);
                            EdmFunctionParameter functionParameter = new EdmFunctionParameter(functionImport, parameter.Name, parameterTypeReference, EdmFunctionParameterMode.In);
                            functionImport.AddParameter(functionParameter);
                        }
                        container.AddElement(functionImport);
                        break;

                    case ProcedureKind.Function:
                        Contract.Assert(false, "Functions are not supported.");
                        break;

                    case ProcedureKind.ServiceOperation:
                        Contract.Assert(false, "ServiceOperations are not supported.");
                        break;
                }
            }
        }