internal CreateFunctionCommand(
            string name, string schemaName, bool isNiladic, bool isComposable,
            bool isAggregate, bool isBuiltIn, string commandText, string returnType, string storeFunctionName,
            IEnumerable<ParameterDefinition> parameterInfos, IRawDataSchemaProcedure dataSchemaProcedure,
            Func<Command, CommandProcessorContext, bool> bindingAction)
            : this(bindingAction)
        {
            if (String.IsNullOrWhiteSpace(returnType))
            {
                throw new ArgumentNullException("returnType");
            }
            ValidateParameterInfo(parameterInfos);

            Name = name;
            SchemaName = schemaName;
            IsNiladic = isNiladic;
            IsComposable = isComposable;
            IsAggregate = isAggregate;
            IsBuiltIn = isBuiltIn;
            CommandText = commandText;
            ReturnType = returnType;
            StoreFunctionName = storeFunctionName;
            ParameterInfos = parameterInfos.ToList();
            DataSchemaProcedure = dataSchemaProcedure;
        }
Esempio n. 2
0
        internal CreateFunctionCommand(
            string name, string schemaName, bool isNiladic, bool isComposable,
            bool isAggregate, bool isBuiltIn, string commandText, string returnType, string storeFunctionName,
            IEnumerable <ParameterDefinition> parameterInfos, IRawDataSchemaProcedure dataSchemaProcedure,
            Func <Command, CommandProcessorContext, bool> bindingAction)
            : this(bindingAction)
        {
            if (String.IsNullOrWhiteSpace(returnType))
            {
                throw new ArgumentNullException("returnType");
            }
            ValidateParameterInfo(parameterInfos);

            Name                = name;
            SchemaName          = schemaName;
            IsNiladic           = isNiladic;
            IsComposable        = isComposable;
            IsAggregate         = isAggregate;
            IsBuiltIn           = isBuiltIn;
            CommandText         = commandText;
            ReturnType          = returnType;
            StoreFunctionName   = storeFunctionName;
            ParameterInfos      = parameterInfos.ToList();
            DataSchemaProcedure = dataSchemaProcedure;
        }
Esempio n. 3
0
        internal static DatabaseObject CreateFromSchemaProcedure(IRawDataSchemaProcedure schemaProcedure)
        {
            var dbObj = new DatabaseObject();

            dbObj.Name   = schemaProcedure.Name;
            dbObj.Schema = schemaProcedure.Schema;
            return(dbObj);
        }
Esempio n. 4
0
 private static string GetReturnType(IRawDataSchemaProcedure procedure, EFArtifact artifact)
 {
     if (procedure.RawReturnValue != null)
     {
         return(GetParameterType(procedure.RawReturnValue, artifact));
     }
     return(null);
 }
Esempio n. 5
0
        internal CreateFunctionCommand(
            string name, string storeFunctionName, string schemaName, string commandText, IEnumerable <ParameterDefinition> parameterInfos,
            IRawDataSchemaProcedure dataSchemaProcedure,
            Func <Command, CommandProcessorContext, bool> bindingAction)
            : this(bindingAction)
        {
            ValidateParameterInfo(parameterInfos);

            Name = name;
            StoreFunctionName   = storeFunctionName;
            SchemaName          = schemaName;
            CommandText         = commandText;
            ParameterInfos      = parameterInfos.ToList();
            DataSchemaProcedure = dataSchemaProcedure;
        }
        internal CreateFunctionCommand(
            string name, string storeFunctionName, string schemaName, string commandText, IEnumerable<ParameterDefinition> parameterInfos,
            IRawDataSchemaProcedure dataSchemaProcedure,
            Func<Command, CommandProcessorContext, bool> bindingAction)
            : this(bindingAction)
        {
            ValidateParameterInfo(parameterInfos);

            Name = name;
            StoreFunctionName = storeFunctionName;
            SchemaName = schemaName;
            CommandText = commandText;
            ParameterInfos = parameterInfos.ToList();
            DataSchemaProcedure = dataSchemaProcedure;
        }
Esempio n. 7
0
 /// <summary>
 ///     Construct a return type to be used for the FunctionImport
 /// </summary>
 private static object ConstructReturnType(
     IRawDataSchemaProcedure schemaProcedure, ConceptualEntityModel cModel,
     StorageEntityModel sModel, string functionImportResultBaseName)
 {
     if (null == schemaProcedure)
     {
         Debug.Fail("null SchemaProcedure not allowed");
         return(null);
     }
     else
     {
         var colCount = schemaProcedure.RawColumns.Count;
         if (0 == colCount)
         {
             // zero columns is equivalent to no return type
             return(Resources.NoneDisplayValueUsedForUX);
         }
         else if (1 == colCount)
         {
             // if 1 columns return a collection of scalars
             var col      = schemaProcedure.RawColumns[0];
             var primType = ModelHelper.GetPrimitiveType(sModel, col.NativeDataType, col.ProviderDataType);
             if (null == primType)
             {
                 Debug.Fail(
                     "Could not find primitive type for column with NativeDataType = " + col.NativeDataType + ", ProviderDataType = "
                     + col.ProviderDataType);
                 return(null);
             }
             else
             {
                 return(primType.GetEdmPrimitiveType());
             }
         }
         else
         {
             // if more than 1 column return a new ComplexType name (this will cause a new ComplexType with that name to be created)
             var proposedName    = String.Format(CultureInfo.CurrentCulture, "{0}_Result", functionImportResultBaseName);
             var complexTypeName = ModelHelper.GetUniqueName(typeof(ComplexType), cModel, proposedName);
             return(complexTypeName);
         }
     }
 }
Esempio n. 8
0
        internal static CreateFunctionCommand GetCreateFunctionCommandFromDataSchemaProcedure(
            IRawDataSchemaProcedure procedure, EFArtifact artifact, Func <Command, CommandProcessorContext, bool> bindingAction = null)
        {
            CreateFunctionCommand createFunctionCommand = null;

            if (procedure.IsFunction)
            {
                createFunctionCommand = new CreateFunctionCommand
                                        (
                    name: ModelHelper.CreateValidSimpleIdentifier(procedure.Name),
                    schemaName: procedure.Schema,
                    isNiladic: !procedure.RawParameters.Any(),
                    isAggregate: false, // figure out if there's some way to determine this from IDataSchemaProcedure
                    isBuiltIn: false,
                    isComposable: true, // figure out if there's some way to determine this from IDataSchemaProcedure
                    commandText: null,
                    returnType: GetReturnType(procedure, artifact),
                    storeFunctionName: procedure.Name,
                    parameterInfos: GetParameterInfos(procedure, artifact),
                    dataSchemaProcedure: procedure,
                    bindingAction: bindingAction
                                        );
            }
            else
            {
                createFunctionCommand = new CreateFunctionCommand
                                        (
                    name: ModelHelper.CreateValidSimpleIdentifier(procedure.Name),
                    storeFunctionName: procedure.Name,
                    schemaName: procedure.Schema,
                    commandText: null,
                    parameterInfos: GetParameterInfos(procedure, artifact),
                    dataSchemaProcedure: procedure,
                    bindingAction: bindingAction
                                        );
            }

            return(createFunctionCommand);
        }
Esempio n. 9
0
        private static IEnumerable <ParameterDefinition> GetParameterInfos(IRawDataSchemaProcedure procedure, EFArtifact artifact)
        {
            var parameterInfos = new List <ParameterDefinition>();

            foreach (var dataSchemaParam in procedure.RawParameters.Where(p => p != null && p.Direction != ParameterDirection.ReturnValue))
            {
                // -1 means that the type is unknown
                if (dataSchemaParam.ProviderDataType != -1)
                {
                    var info = new ParameterDefinition();
                    parameterInfos.Add(info);
                    info.Name = ModelHelper.CreateValidSimpleIdentifier(dataSchemaParam.Name);

                    switch (dataSchemaParam.Direction)
                    {
                    case ParameterDirection.Input:
                        info.Mode = Parameter.InOutMode.In.ToString();
                        break;

                    case ParameterDirection.InputOutput:
                        info.Mode = Parameter.InOutMode.InOut.ToString();
                        break;

                    case ParameterDirection.Output:
                        info.Mode = Parameter.InOutMode.Out.ToString();
                        break;

                    case ParameterDirection.ReturnValue:
                    default:
                        Debug.Fail("Could not determine parameter mode");
                        info.Mode = Parameter.InOutMode.Unknown.ToString();
                        break;
                    }
                    info.Type = GetParameterType(dataSchemaParam, artifact);
                }
            }
            return(parameterInfos);
        }
 /// <summary>
 ///     Construct a return type to be used for the FunctionImport
 /// </summary>
 private static object ConstructReturnType(
     IRawDataSchemaProcedure schemaProcedure, ConceptualEntityModel cModel,
     StorageEntityModel sModel, string functionImportResultBaseName)
 {
     if (null == schemaProcedure)
     {
         Debug.Fail("null SchemaProcedure not allowed");
         return null;
     }
     else
     {
         var colCount = schemaProcedure.RawColumns.Count;
         if (0 == colCount)
         {
             // zero columns is equivalent to no return type
             return Resources.NoneDisplayValueUsedForUX;
         }
         else if (1 == colCount)
         {
             // if 1 columns return a collection of scalars
             var col = schemaProcedure.RawColumns[0];
             var primType = ModelHelper.GetPrimitiveType(sModel, col.NativeDataType, col.ProviderDataType);
             if (null == primType)
             {
                 Debug.Fail(
                     "Could not find primitive type for column with NativeDataType = " + col.NativeDataType + ", ProviderDataType = "
                     + col.ProviderDataType);
                 return null;
             }
             else
             {
                 return primType.GetEdmPrimitiveType();
             }
         }
         else
         {
             // if more than 1 column return a new ComplexType name (this will cause a new ComplexType with that name to be created)
             var proposedName = String.Format(CultureInfo.CurrentCulture, "{0}_Result", functionImportResultBaseName);
             var complexTypeName = ModelHelper.GetUniqueName(typeof(ComplexType), cModel, proposedName);
             return complexTypeName;
         }
     }
 }
Esempio n. 11
0
 private void Initialize(IRawDataSchemaProcedure schemaProcedure)
 {
     _schemaProcedure = schemaProcedure;
 }
Esempio n. 12
0
 internal CreateMatchingFunctionImportCommand(
     IRawDataSchemaProcedure schemaProcedure, Func <Command, CommandProcessorContext, bool> bindingAction)
     : base(bindingAction)
 {
     Initialize(schemaProcedure);
 }
 internal CreateMatchingFunctionImportCommand(
     IRawDataSchemaProcedure schemaProcedure, Func<Command, CommandProcessorContext, bool> bindingAction)
     : base(bindingAction)
 {
     Initialize(schemaProcedure);
 }
 private void Initialize(IRawDataSchemaProcedure schemaProcedure)
 {
     _schemaProcedure = schemaProcedure;
 }
 private static string GetReturnType(IRawDataSchemaProcedure procedure, EFArtifact artifact)
 {
     if (procedure.RawReturnValue != null)
     {
         return GetParameterType(procedure.RawReturnValue, artifact);
     }
     return null;
 }
        private static IEnumerable<ParameterDefinition> GetParameterInfos(IRawDataSchemaProcedure procedure, EFArtifact artifact)
        {
            var parameterInfos = new List<ParameterDefinition>();

            foreach (var dataSchemaParam in procedure.RawParameters.Where(p => p != null && p.Direction != ParameterDirection.ReturnValue))
            {
                // -1 means that the type is unknown
                if (dataSchemaParam.ProviderDataType != -1)
                {
                    var info = new ParameterDefinition();
                    parameterInfos.Add(info);
                    info.Name = ModelHelper.CreateValidSimpleIdentifier(dataSchemaParam.Name);

                    switch (dataSchemaParam.Direction)
                    {
                        case ParameterDirection.Input:
                            info.Mode = Parameter.InOutMode.In.ToString();
                            break;
                        case ParameterDirection.InputOutput:
                            info.Mode = Parameter.InOutMode.InOut.ToString();
                            break;
                        case ParameterDirection.Output:
                            info.Mode = Parameter.InOutMode.Out.ToString();
                            break;
                        case ParameterDirection.ReturnValue:
                        default:
                            Debug.Fail("Could not determine parameter mode");
                            info.Mode = Parameter.InOutMode.Unknown.ToString();
                            break;
                    }
                    info.Type = GetParameterType(dataSchemaParam, artifact);
                }
            }
            return parameterInfos;
        }
        internal static CreateFunctionCommand GetCreateFunctionCommandFromDataSchemaProcedure(
            IRawDataSchemaProcedure procedure, EFArtifact artifact, Func<Command, CommandProcessorContext, bool> bindingAction = null)
        {
            CreateFunctionCommand createFunctionCommand = null;
            if (procedure.IsFunction)
            {
                createFunctionCommand = new CreateFunctionCommand
                    (
                    name: ModelHelper.CreateValidSimpleIdentifier(procedure.Name),
                    schemaName: procedure.Schema,
                    isNiladic: !procedure.RawParameters.Any(),
                    isAggregate: false, // figure out if there's some way to determine this from IDataSchemaProcedure
                    isBuiltIn: false,
                    isComposable: true, // figure out if there's some way to determine this from IDataSchemaProcedure
                    commandText: null,
                    returnType: GetReturnType(procedure, artifact),
                    storeFunctionName: procedure.Name,
                    parameterInfos: GetParameterInfos(procedure, artifact),
                    dataSchemaProcedure: procedure,
                    bindingAction: bindingAction
                    );
            }
            else
            {
                createFunctionCommand = new CreateFunctionCommand
                    (
                    name: ModelHelper.CreateValidSimpleIdentifier(procedure.Name),
                    storeFunctionName: procedure.Name,
                    schemaName: procedure.Schema,
                    commandText: null,
                    parameterInfos: GetParameterInfos(procedure, artifact),
                    dataSchemaProcedure: procedure,
                    bindingAction: bindingAction
                    );
            }

            return createFunctionCommand;
        }