Add FIELD Function, fix virtual columns
This commit is contained in:
@@ -12,6 +12,9 @@ Namespace Templates
|
||||
Public Property Parameter2 As String
|
||||
Public Property FinalSQL As String
|
||||
|
||||
''' <summary>
|
||||
''' Tabledata from XSD
|
||||
''' </summary>
|
||||
Public Property Tables As New List(Of Table)
|
||||
|
||||
Public Property InputDirectory As String
|
||||
@@ -68,6 +71,9 @@ Namespace Templates
|
||||
End If
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Table from XSD
|
||||
''' </summary>
|
||||
Class Table
|
||||
Public Property Name As String
|
||||
Public Property Columns As New List(Of Column)
|
||||
|
||||
@@ -240,9 +240,11 @@ Namespace Templates
|
||||
Return pTemplate
|
||||
End If
|
||||
|
||||
For Each oTable In pTemplate.Tables
|
||||
Dim oTemplate = CreateVirtualColumns(pTemplate, pTemplateConfig)
|
||||
|
||||
For Each oTable In oTemplate.Tables
|
||||
For Each oColumn As Template.Column In oTable.Columns
|
||||
Dim oConfig = pTemplateConfig.GetColumn(oColumn.Name, oTable.Name)
|
||||
Dim oConfig As TemplateConfigItem = pTemplateConfig.GetColumn(oColumn.Name, oTable.Name)
|
||||
|
||||
If oConfig Is Nothing Then
|
||||
oConfig = New TemplateConfigItem With {
|
||||
@@ -255,6 +257,31 @@ Namespace Templates
|
||||
Next
|
||||
Next
|
||||
|
||||
Return oTemplate
|
||||
End Function
|
||||
|
||||
Private Function CreateVirtualColumns(pTemplate As Template, pTemplateConfig As TemplateConfig) As Template
|
||||
For Each oConfigItem In pTemplateConfig.Items
|
||||
' Find the table that relates to this config item
|
||||
Dim oTable = pTemplate.Tables.Where(Function(table) table.Name = oConfigItem.Table).FirstOrDefault()
|
||||
|
||||
If oTable Is Nothing Then
|
||||
Logger.Warn("Table [{0}] for item [{1}] does exist in this Template!", oConfigItem.Table, oConfigItem.Name)
|
||||
Continue For
|
||||
End If
|
||||
|
||||
Dim oColumnExists = oTable.Columns.Any(Function(column) column.Name = oConfigItem.Name)
|
||||
|
||||
If oColumnExists = False And oConfigItem.IsVirtual = True Then
|
||||
oTable.Columns.Add(New Template.Column() With {
|
||||
.Name = oConfigItem.Name,
|
||||
.Config = oConfigItem,
|
||||
.DataType = Constants.ColumnType.String,
|
||||
.IsRequired = False
|
||||
})
|
||||
End If
|
||||
Next
|
||||
|
||||
Return pTemplate
|
||||
End Function
|
||||
|
||||
|
||||
Reference in New Issue
Block a user