Example #1
0
 /// <summary>
 /// Adds given <see cref="StoredProcedure"/> to <see cref="Procedures"/> collection.
 /// </summary>
 /// <param name="procedure">Procedure to add.</param>
 public void Add(StoredProcedure procedure)
 {
     this.Procedures.Add(procedure);
 }
        private StoredProcedure ConvertToStoredProcedure(Function customFunction)
        {
            string functionName = this.GetFunctionName(customFunction);
            string schema = this.GetSchemaName(customFunction);

            var storedProcedure = new StoredProcedure(schema, functionName);
            foreach (var parameter in customFunction.Parameters)
            {
                storedProcedure.Parameters.Add(this.ConvertToDatabaseFunctionParameter(parameter));
            }

            var bodyAnnotation = customFunction.Annotations.OfType<StoreFunctionBodyAnnotation>().SingleOrDefault();
            if (bodyAnnotation != null)
            {
                storedProcedure.Body = bodyAnnotation.Body;
            }

            foreach (var returnTypeAnnotation in customFunction.Annotations.OfType<StoredProcedureReturnTypeFunctionAnnotation>())
            {
                var storedProcedureReturnTypeAnnotation = new StoredProcedureReturnTypeAnnotation(this.ConvertToDatabaseType(returnTypeAnnotation.ReturnType));
                storedProcedureReturnTypeAnnotation.BodyGenerationAnnotation = this.GetStoreFunctionBodyGenerationInfoToStoreItem(returnTypeAnnotation.BodyGenerationAnnotation);
                storedProcedure.Annotations.Add(storedProcedureReturnTypeAnnotation);
            }

            return storedProcedure;
        }