在 Acumatica 中将 SQL 转换为 BQL [英] Translate SQL to BQL in Acumatica

查看:8
本文介绍了在 Acumatica 中将 SQL 转换为 BQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从SQL翻译过来

select * from table where table.field in('A','B') 

到 Acumatica BQL.

to Acumatica BQL.

请帮助我获取此信息.

推荐答案

有几种方法可以做到:

1.使用 In3/Or 和 BQL 常量

您需要做的第一件事是创建表示A"和B"的 BQL 常量.像这样:

First thing you'll need to do is create BQL constants representing 'A' and 'B'. Like that:

public class constantA: PX.Data.Constant<string>
{
    public constantA() : base("A") { }
}
public class constantB: PX.Data.Constant<string>
{
    public constantB() : base("B") { }
}

这将允许您在 BQL 查询中使用 A 和 B.(您可以在 T200 培训中找到更多信息,示例 3.1:为查询页面提供数据)(您可以根据参数类型使用PX.Data.ConstantPX.Data.Constant等)

This will allow you to use A and B in your BQL query. (You can find more info about that in T200 Training, Example 3.1: Providing Data for the Inquiry Page) (you can use PX.Data.Constant<int>, PX.Data.Constant<decimal>, etc. depending on parameter type)

之后你可以编写 BQL:

After that you can compose BQL:

PXSelect<Table, Where<Table.field, In3<constantA, constantB>>>

(或 PXSelect, Or>>>)

2.使用 In 和 Required

PXSelect<Table, Where<Table.field, In<Required<Table.field>>>>.Select(graph, new string[]{"A","B"}) //you may need to use array of objects instead of array of strings

这种方式允许您在运行时组合常量列表并将其作为参数传递给查询.参数应为对应类型的数组(本例中为字符串数组).

this way allows you to compose list of constants at runtime and pass it like a parameter to the query. Parameter should be array of the corresponding type(it's strings array in this example).

这篇关于在 Acumatica 中将 SQL 转换为 BQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆