BIML class nugget error: 'AstTableNode' does not contain a definition for 'GetTag' and no accessible extension method 'GetTag'

BIML class nugget error: 'AstTableNode' does not contain a definition for 'GetTag' and no accessible extension method 'GetTag'

我创建了一个 HelperFunctions.cs 文件,其中包含以下内容:

using Varigence.Languages.Biml.Table;
public static class HelperFunctions
{
  public static string GetDisplayTableName(AstTableNode table) 
  {
    return table.GetTag("DatabaseName").ToUpper() + "_" + table.Schema.Name.ToUpper() + "_" + table.Name.ToUpper();

  }

}

但是它无法识别 GetTag() 并抛出错误:

'AstTableNode' 不包含 'GetTag' 的定义,并且找不到可访问的扩展方法 'GetTag' 接受类型 'AstTableNode' 的第一个参数(您是否缺少使用指令或程序集引用?)。 我需要添加什么才能使这项工作正常进行? 谢谢 乔恩

静态方法需要参数前缀为this

SO_63828312.cs

using System.Collections.Generic;
using System.Linq;
using System.Text;
using Varigence.Biml.Extensions;
using Varigence.Languages.Biml.Table;
public static class HelperFunctions
{
    public static string GetDisplayTableName(this AstTableNode table)
    {
        return table.GetTag("DatabaseName").ToUpper() + "_" + table.Schema.Name.ToUpper() + "_" + table.Name.ToUpper();

    }

}

我的静态 Biml 定义了一个 table,它需要一个模式,需要一个数据库,需要一个连接。所有这些都是为了让我们得到一个 table,它的 AnnotationType 为 Tag,值为 AW。

SO_63828312.T0.biml

<Biml xmlns="http://schemas.varigence.com/biml.xsd">
    <Connections>
        <OleDbConnection ConnectionString="Data Source=localhost\dev2017;Initial Catalog=tempdb;Provider=SQLNCLI11.1;Integrated Security=SSPI;Auto Translate=False;Packet Size=32767;" Name="AdventureWorks" />
    </Connections>
    <Databases>
        <Database Name="AW" ConnectionName="AdventureWorks" />
    </Databases>
    <Schemas>
        <Schema DatabaseName="AW" Name="dbo" />
    </Schemas>
    <Tables>
        <Table Name="foo" SchemaName="AW.dbo">
            <Annotations>
                <Annotation Tag="DatabaseName" AnnotationType="Tag">AW</Annotation>
            </Annotations>
            <Columns>
                <Column Name="Col1" DataType="Int32"></Column>
            </Columns>
        </Table>
    </Tables>
</Biml>

一级执行。这开始了我们的动态分层。因为只有一个,所以我没有明确地给它一个,但是如果你有多个层,你会想要提供一个指令。

在这里,我列举了我的表集合(在前面的层中定义),对于我找到的每个 table,我写下 table 名称和标签值

SO_63828312.T1.biml

<#@ code file="SO_63828312.cs" #>


<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<#
string template =  "<!-- {0}|{1} -->";
foreach(var t in this.RootNode.Tables)
{
    WriteLine(string.Format(template, t.Name, t.GetDisplayTableName()));
}
#>
</Biml>