How to use a DataSource based on condition being true?

点点圈 提交于 2019-12-25 05:22:32

问题


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!


回答1:


You did not specify the tables and relations, but using these datasources as an example:

  • CustTable
    • CustTrans (JoinMode: ExistsJoin)
    • CustInvoiceJour (JoinMode: ExistsJoin)

Suppose you want to exists join on either CustTrans or CustInvoiceJour?

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);

This should be done before super() in the executeQuery method of the CustTable datasource.



来源:https://stackoverflow.com/questions/12256065/how-to-use-a-datasource-based-on-condition-being-true

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!