在where语句中使用方法

Ven*_*ion 2 x++ axapta

Table table;

    select * 
        from table
        where this.id != table.id
            && this.foo(table);
Run Code Online (Sandbox Code Playgroud)

我试图从X ++代码中的表中进行选择.该表与表(this)中的记录进行比较.

如果记录的id和表中的另一个记录不相等,则记录应添加到选择中,并将其他几个条件foo()评估为true.计划是this.foo(table)将记录与表中的其他记录一起进行评估.

当我foo()直接将代码插入到调用中时,它可以正常工作.但是,在调用方法时,它似乎table没有任何引用.

我怎么不理解方式,选择陈述有用吗?方法只评估一次吗?

10p*_*10p 7

您不能在AX where中的select语句中使用表达式(也不是任何其他部分)中的方法.您的示例将无法成功编译.

您可以尝试foowhere表达式中合并方法的逻辑,也可以单独遍历select语句的结果和foo每个记录的调用方法,例如:

Table table;

while select table
    where table.id != this.id
{
    if (this.foo(table))
    {
        info(table.id);
    }
}
Run Code Online (Sandbox Code Playgroud)