我们经常需要根据表之间的关系用代码创建query,SysQuery这个类提供了一个方法queryFromTableRelation,当然这个方法的代码跟我们平常根据表之间的关系构造query的过程是完全一样的,不过它做成了通用的方法,直接调用它就不用自己每次都重复劳动了,另外SysQuery里还有几个不错的方法,值得看一下source.
public static Query queryFromTableRelation(Common _parentTable, TableId _relationTableId, boolean _update = false, boolean _noRelationNoRecords = true)
功能:根据表的关系构造Query
参数说明:
_parentTable:父表
_relationTableId:子表Id
_update :是否允许query更新数据库记录
_noRelationNoRecords :如果没有关系就不返回记录,这一点是靠如下语句实现的:








这个函数的代码还是挺漂亮的,可以看做DictionRaltaion类应用的示例代码,呵呵.