private static void LoadFunctionOutputColumns(TestSchema schema, TestFunction function_source, CreateFunctionStatement stmt_CreateFunction) { ProcedureGenerator.LoadFunctionOutputColumns(schema, function_source, function_source.FunctionBodyScript, (col) => { function_source.AddFunctionColumn(col.OutputColumnName, col.ColumnType.ColumnDbType, col.ColumnType.AllowNull); }); }
private static void LoadViewOutputColumnsX(TestSchema schema, TestView vw, CreateViewStatement stmt_CreateFunction) { ProcedureGenerator.LoadViewOutputColumns(schema, vw.Body, (col) => { vw.AddViewColumn(col.OutputColumnName, col.ColumnType.ColumnDbType, col.ColumnType.AllowNull, col.OutputColumnName); }); }
internal static TestFunction LoadFunctionMetatadaFromDDL(TestSchema schema, string ddl) { TSqlFragment sqlF = ScriptDomFacade.Parse(ddl); CreateFunctionStatement stmt_CreateFunction = (CreateFunctionStatement)((TSqlScript)sqlF).Batches[0].Statements[0]; string schemaName = stmt_CreateFunction.Name.SchemaIdentifier.Dequote(); string functionName = stmt_CreateFunction.Name.BaseIdentifier.Dequote(); if (stmt_CreateFunction.StatementList != null) { // 'hlsyssec_query_agentsystemacl' return(LoadMultiStatementTableValuedFunction(schemaName, functionName, stmt_CreateFunction)); } // inline 'hlsur_query_surveyresults' string functionBody = GetFragmentStreamAsText(((SelectFunctionReturnType)stmt_CreateFunction.ReturnType).SelectStatement); var function = new TestFunction(schemaName, functionName, functionBody, f => LoadFunctionOutputColumns(schema, f, stmt_CreateFunction)); foreach (ProcedureParameter prm in stmt_CreateFunction.Parameters) { string parameterName = prm.VariableName.Dequote(); var parameterDbType = ProcedureGenerator.ResolveToDbDataType(prm.DataType); function.AddParameter(parameterName, parameterDbType, true); } return(function); }
private static TestTable LoadTableFromDDL(string ddl) { TSqlFragment sqlF = ScriptDomFacade.Parse(ddl); CreateTableStatement stmt_CreateTable = (CreateTableStatement)((TSqlScript)sqlF).Batches[0].Statements[0]; string schemaName = stmt_CreateTable.SchemaObjectName.SchemaIdentifier.Dequote(); string tableName = stmt_CreateTable.SchemaObjectName.BaseIdentifier.Dequote(); var table = new TestTable(schemaName, tableName); foreach (ColumnDefinition col in stmt_CreateTable.Definition.ColumnDefinitions) { string columnName = col.ColumnIdentifier.Dequote(); var columnDbType = ProcedureGenerator.ResolveToDbDataType(col.DataType); table.AddColumn(columnName, columnDbType, true); } return(table); }
private static TestFunction LoadMultiStatementTableValuedFunction(string schemaName, string functionName, CreateFunctionStatement stmt_CreateFunction) { if (stmt_CreateFunction.ReturnType is TableValuedFunctionReturnType tvfReturnType) { TestFunction function = new TestFunction(schemaName, functionName, "", (x) => { }); //tvfReturnType.DeclareTableVariableBody.VariableName var tableBody = tvfReturnType.DeclareTableVariableBody; foreach (ColumnDefinition col in tableBody.Definition.ColumnDefinitions) { string columnName = col.ColumnIdentifier.Dequote(); var columnDbType = ProcedureGenerator.ResolveToDbDataType(col.DataType); function.AddFunctionColumn(columnName, columnDbType, true); } return(function); } throw new NotImplementedException(stmt_CreateFunction.ReturnType.WhatIsThis()); }
private void Initialize(string accessionPrefix, Patient patient) { Accession = AccessionGenerator.GetNewAccession(accessionPrefix); Procedure = ProcedureGenerator.GetProcedure(); Patient = patient; }