示例#1
0
        /// <summary>
        /// Generates table function model from schema data.
        /// </summary>
        /// <param name="dataContext">Data context model.</param>
        /// <param name="func">Function schema.</param>
        /// <param name="defaultSchemas">List of default database schema names.</param>
        private void BuildTableFunction(DataContextModel dataContext, TableFunction func, ISet <string> defaultSchemas)
        {
            var(name, isNonDefaultSchema) = ProcessObjectName(func.Name, defaultSchemas);

            var method = new MethodModel(
                _namingServices.NormalizeIdentifier(_options.DataModel.ProcedureNameOptions,
                                                    (func.Name.Package != null ? $"{func.Name.Package}_" : null) + name.Name))
            {
                Modifiers = Modifiers.Public,
                Summary   = func.Description
            };

            var metadata = new TableFunctionMetadata()
            {
                Name = name
            };
            var funcModel = new TableFunctionModel(
                name,
                method,
                metadata,
                _namingServices.NormalizeIdentifier(_options.DataModel.TableFunctionMethodInfoFieldNameOptions, func.Name.Name))
            {
                Error = func.SchemaError?.Message
            };

            BuildParameters(func.Parameters, funcModel.Parameters);

            if (func.Result != null)
            {
                funcModel.Result = PrepareResultSetModel(func.Name, func.Result);
            }

            _interceptors.PreprocessTableFunction(_languageProvider.TypeParser, funcModel);

            if (isNonDefaultSchema && _options.DataModel.GenerateSchemaAsType)
            {
                GetOrAddAdditionalSchema(dataContext, func.Name.Schema !).TableFunctions.Add(funcModel);
            }
            else
            {
                dataContext.TableFunctions.Add(funcModel);
            }
        }
示例#2
0
 /// <summary>
 /// Using this method user could modify table function code generation options:
 /// <list type="bullet">
 /// <item>Function metadata: <see cref="TableFunctionModel.Metadata"/></item>
 /// <item>Return table descriptor: <see cref="TableFunctionModel.Result"/></item>
 /// <item>Error, returned by data set schema load procedure: <see cref="TableFunctionModelBase.Error"/></item>
 /// <item>Metadata (function name): <see cref="TableFunctionModelBase.Name"/></item>
 /// <item>Method code-generation options: <see cref="FunctionModelBase.Method"/></item>
 /// <item>Parameters: <see cref="FunctionModelBase.Parameters"/></item>
 /// </list>
 /// </summary>
 /// <param name="typeParser">Type parser service to create type tokens.</param>
 /// <param name="functionModel">Function model descriptor.</param>
 public virtual void PreprocessTableFunction(ITypeParser typeParser, TableFunctionModel functionModel)
 {
 }