如何根据条件为真使用数据源? [英] How to use a DataSource based on condition being true?

查看:96
本文介绍了如何根据条件为真使用数据源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试基于特定条件为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)

      假设您要在 CustTransCustInvoiceJour上存在联接?

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

      这应该在CustTable数据源的executeQuery方法中的super()之前完成.

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

      这篇关于如何根据条件为真使用数据源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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