访问辅助实体的属性

时间:2019-02-09 05:42:07

标签: gosu guidewire

有人可以帮助我解决以下问题吗? 在下面的Gosu代码中,如何在查询结果中将城市信息包含在地址表中(无需翻转表-从地址表开始)?地址表有一个指向用户表的外键,但是没有外键。行查询可以做到吗? 非常感谢

uses gw.api.database.Query

// -- query the User entity --
var queryUser = Query.make(User)

// -- select only User instances who last updated addresses in the city of Chicago --
var tableAddress = queryUser.join(Address, "UpdateUser")
tableAddress.compare("City", Equals, "Chicago") 

// -- fetch the User instances with a for loop and print them --
var result = queryUser.select()

for (user in result) {
    print (user.DisplayName)
}

1 个答案:

答案 0 :(得分:0)

自从地址以来,用户FK为什么不打开桌子?

uses gw.api.database.Query

// -- query the Address entity --
var queryAddress = Query.make(Address)
queryAddress.compare("City", Equals, "Chicago") 

// -- select only User instances who last updated addresses in the city of Chicago --
var tableUser = queryAddress.join(Address#UpdateUser)

// -- fetch the Addresses instances with a for loop and print them --
var result = tableUser.select()

for (address in result) {
    print(address.City?.DisplayName)
    print(address.UpdateUser?.DisplayName)
}