简体   繁体   English

如何在GOSU中写和比较

[英]How to write and in one Compare in GOSU

I have a query below and need to combine the 2nd and 3rd.compare condition with 'AND' operator我在下面有一个查询,需要将 2nd 和 3rd.compare 条件与“AND”运算符结合起来

var query = ii.join(InvoiceItem#PolicyPeriod)
        .compare(PolicyPeriod#Plan, Relop.NotEquals, xyzPlan)
        .compareIn(PolicyPeriod#ProdType, {Prod.TC_FREE, Prod.TC_UNIQ})
        .compareIn(PolicyPeriod#Elig,{OffElig.TC_Yes})

Second compareIn statement should be like below in SQL but do not know how to combine two variables in one compare with AND operator.第二个 compareIn 语句应该如下 SQL 但不知道如何使用 AND 运算符将两个变量组合在一个比较中。

if ( prodtype in ('FREE','UNIQ') and Elig = 'YES')

Any Advice!!

You can use .and() method from the QueryAPI:您可以使用 QueryAPI 中的.and()方法:

var query = ii.join(InvoiceItem#PolicyPeriod)
    .compare(PolicyPeriod#Plan, Relop.NotEquals, xyzPlan)
    .and(\and1 -> {
        and1.compareIn(PolicyPeriod#ProdType, {Prod.TC_FREE, Prod.TC_UNIQ})
        and1.compareIn(PolicyPeriod#Elig, {OffElig.TC_Yes})
    })

In the same manner, you can use .or() method or even combine and() and or() in one statement.以同样的方式,您可以使用.or()方法,甚至可以将and()or()组合在一个语句中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM