更新时间:2023-02-07 12:57:11
在 Biml 中有几种方法可以过滤列列表.
There are several ways to filter a column list in Biml.
您可以过滤列名或部分列名:
You can filter on column names or parts of column names:
<#=table.GetColumnList(c => c.Name != "dwh_timestamp")#>
<#=table.GetColumnList(c => c.Name.StartsWith("dwh_"))#>
更可重用的解决方案是在列上创建注释并在注释上过滤:
A more reusable solution is to create Annotations on the columns and filter on the annotation:
<Columns>
<# foreach (var column in table.Columns) { #>
<#=column.GetBiml()#>
<# } #>
<Column Name="dwh_timestamp" DataType="DateTime" IsNullable="true">
<Annotations>
<Annotation AnnotationType="Tag" Tag="IsDWHColumn">Yes</Annotation>
</Annotations>
</Column>
</Columns>
<#=table.GetColumnList(c => c.GetTag("IsDWHColumn") != "Yes")#>
当然,您可以选择自己的注释策略.您可能希望使用true"和false"而不是Yes"和No",或者反转注释逻辑以指定哪些列是源列而不是 DWH 列.
You choose your own annotation strategy, of course. You may want to use "true" and "false" instead of "Yes" and "No", or reverse the annotation logic to specify which columns are source columns instead of DWH columns.