在 where 语句中使用方法
Use methods in where statements
Table table;
select *
from table
where this.id != table.id
&& this.foo(table);
我正在尝试在 X++ 代码中从 table 生成一个 selection。
table 与来自 table (this
) 的记录进行比较。
如果记录的 ID 与 table 中的另一条记录不相等且 foo()
中的其他几个条件评估为真,则应将记录添加到 selection .
计划是使 this.foo(table)
与 table 中的其他记录一起评估记录。
当我将 foo()
中的代码直接插入到调用中时,它工作得很好。但是,调用该方法时,似乎 table
没有任何引用。
我对 select 语句有效的方式有什么不理解的?
方法只评估一次吗?
您不能在 AX 中 select
语句的 where
表达式(也不能在任何其他部分)中使用方法。您的示例将无法编译成功。
您可以尝试将 foo
方法的逻辑合并到 where
表达式中,或者遍历 select
语句的结果并调用方法 foo
每条记录单独例如:
Table table;
while select table
where table.id != this.id
{
if (this.foo(table))
{
info(table.id);
}
}
Table table;
select *
from table
where this.id != table.id
&& this.foo(table);
我正在尝试在 X++ 代码中从 table 生成一个 selection。
table 与来自 table (this
) 的记录进行比较。
如果记录的 ID 与 table 中的另一条记录不相等且 foo()
中的其他几个条件评估为真,则应将记录添加到 selection .
计划是使 this.foo(table)
与 table 中的其他记录一起评估记录。
当我将 foo()
中的代码直接插入到调用中时,它工作得很好。但是,调用该方法时,似乎 table
没有任何引用。
我对 select 语句有效的方式有什么不理解的? 方法只评估一次吗?
您不能在 AX 中 select
语句的 where
表达式(也不能在任何其他部分)中使用方法。您的示例将无法编译成功。
您可以尝试将 foo
方法的逻辑合并到 where
表达式中,或者遍历 select
语句的结果并调用方法 foo
每条记录单独例如:
Table table;
while select table
where table.id != this.id
{
if (this.foo(table))
{
info(table.id);
}
}