private void AddOperationImport(CsdlOperationImport operationImport, List <IEdmEntityContainerElement> elements)
        {
            var functionImport = operationImport as CsdlFunctionImport;
            var actionImport   = operationImport as CsdlActionImport;
            CsdlSemanticsOperationImport semanticsOperation = null;
            EdmSchemaElementKind         filterKind         = EdmSchemaElementKind.Action;

            if (functionImport != null)
            {
                filterKind = EdmSchemaElementKind.Function;
            }

            // OperationImports only work with non-bound operations hence this extra logic in the where clause
            var operations = this.context.FindOperations(operationImport.SchemaOperationQualifiedTypeName).Where(o => o.SchemaElementKind == filterKind && !o.IsBound);

            int operationsCount = 0;

            foreach (IEdmOperation operation in operations)
            {
                if (functionImport != null)
                {
                    semanticsOperation = new CsdlSemanticsFunctionImport(this, functionImport, (IEdmFunction)operation);
                }
                else
                {
                    Debug.Assert(actionImport != null, "actionImport should not be null");
                    semanticsOperation = new CsdlSemanticsActionImport(this, actionImport, (IEdmAction)operation);
                }

                operationsCount++;
                elements.Add(semanticsOperation);
            }

            // If none have been created then its an unresolved operation.
            if (operationsCount == 0)
            {
                if (filterKind == EdmSchemaElementKind.Action)
                {
                    var action = new UnresolvedAction(operationImport.SchemaOperationQualifiedTypeName, Edm.Strings.Bad_UnresolvedOperation(operationImport.SchemaOperationQualifiedTypeName), operationImport.Location);
                    semanticsOperation = new CsdlSemanticsActionImport(this, actionImport, action);
                }
                else
                {
                    Debug.Assert(filterKind == EdmSchemaElementKind.Function, "Should be a function");
                    var function = new UnresolvedFunction(operationImport.SchemaOperationQualifiedTypeName, Edm.Strings.Bad_UnresolvedOperation(operationImport.SchemaOperationQualifiedTypeName), operationImport.Location);
                    semanticsOperation = new CsdlSemanticsFunctionImport(this, functionImport, function);
                }

                elements.Add(semanticsOperation);
            }
        }
        private void AddOperationImport(CsdlOperationImport operationImport, List<IEdmEntityContainerElement> elements)
        {
            var functionImport = operationImport as CsdlFunctionImport;
            var actionImport = operationImport as CsdlActionImport;
            CsdlSemanticsOperationImport semanticsOperation = null;
            EdmSchemaElementKind filterKind = EdmSchemaElementKind.Action;
            if (functionImport != null)
            {
                filterKind = EdmSchemaElementKind.Function;
            }

            // OperationImports only work with non-bound operations hence this extra logic in the where clause
            var operations = this.context.FindOperations(operationImport.SchemaOperationQualifiedTypeName).Where(o => o.SchemaElementKind == filterKind && !o.IsBound);

            int operationsCount = 0;
            foreach (IEdmOperation operation in operations)
            {
                if (functionImport != null)
                {
                    semanticsOperation = new CsdlSemanticsFunctionImport(this, functionImport, (IEdmFunction)operation);
                }
                else
                {
                    Debug.Assert(actionImport != null, "actionImport should not be null");
                    semanticsOperation = new CsdlSemanticsActionImport(this, actionImport, (IEdmAction)operation);
                }

                operationsCount++;
                elements.Add(semanticsOperation);
            }

            // If none have been created then its an unresolved operation.
            if (operationsCount == 0)
            {
                if (filterKind == EdmSchemaElementKind.Action)
                {
                    var action = new UnresolvedAction(operationImport.SchemaOperationQualifiedTypeName, Edm.Strings.Bad_UnresolvedOperation(operationImport.SchemaOperationQualifiedTypeName), operationImport.Location);
                    semanticsOperation = new CsdlSemanticsActionImport(this, actionImport, action);
                }
                else
                {
                    Debug.Assert(filterKind == EdmSchemaElementKind.Function, "Should be a function");
                    var function = new UnresolvedFunction(operationImport.SchemaOperationQualifiedTypeName, Edm.Strings.Bad_UnresolvedOperation(operationImport.SchemaOperationQualifiedTypeName), operationImport.Location);
                    semanticsOperation = new CsdlSemanticsFunctionImport(this, functionImport, function);
                }

                elements.Add(semanticsOperation);
            }
        }