如何根据条件为真使用数据源? [英] How to use a DataSource based on condition being true?
问题描述
我目前正在尝试基于特定条件为true的情况下使用数据源构建查询.说如果value == 1,请使用数据源1.如果value == 2,请使用数据源2.
I'm currently trying to build a query that uses a datasource based on a particular condition being true. Say "if value == 1, use datasource 1. If value == 2, use datasource 2.
这些表已经进入了我的数据源的几个层次.
These tables are already a couple of levels into my datasources.
无法在任何地方找到有关此信息!
Haven't been able to find info on this anywhere!
推荐答案
您没有指定表和关系,而是使用以下数据源作为示例:
You did not specify the tables and relations, but using these datasources as an example:
- 客户表
- CustTrans(JoinMode:ExistsJoin)
- CustInvoiceJour(加入模式:ExistsJoin)
- CustTable
- CustTrans (JoinMode: ExistsJoin)
- CustInvoiceJour (JoinMode: ExistsJoin)
假设您要在
CustTrans
或CustInvoiceJour
上存在联接?Suppose you want to exists join on either
CustTrans
orCustInvoiceJour
?这可以通过启用和禁用相应的数据源来实现:
This can be accomplished by enabling and disabling the corresponding datasources:
custTable_ds.query().datasourceTable(tableNum(CustTrans)).enabled(!useInvoice); custTable_ds.query().datasourceTable(tableNum(CustInvoiceJour )).enabled(useInvoice);
这应该在
CustTable
数据源的executeQuery
方法中的super()
之前完成.This should be done before
super()
in theexecuteQuery
method of theCustTable
datasource.这篇关于如何根据条件为真使用数据源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!