wcdb
wcdb copied to clipboard
查询条件是否可以动态填写
The language of WCDB
e.g. Swift
The version of WCDB
e.g. v1.0.8
The platform of WCDB
e.g. iOS
The installation of WCDB
e.g. Cocoapods
What's the issue?
您好,我目前才开始用swift。目前在从CoreData迁移到WCDB。目前遇到的问题是如果是我这查询的条件是动态的。原先在CoreData用的谓词可以用String拼接条件。但是在WCDB.swift 中是Condition这个类,请问该如何动态添加条件例如:一个姓x的学生在多个年级的总人数该如何拼接 该如何动态拼接年级呢?并加||分开
// 姓的条件
WCDBStudent.Properties.name.like(王%)
// 年级的条件
WCDBStudent.Properties.class.like(“年级“%)
完整的代码如下,年级和姓名是动态的。如果年级和姓名过多无法实现自动拼接。手动拼接代码如下:
(WCDBStudent.Properties.name.like("王%") || WCDBStudent.Properties.name.like("李%") ) && (WCDBStudent.Properties.class.like(一%) || WCDBStudent.Properties.class.like(三%) || WCDBStudent.Properties.class.like(五%) )
有什么方法可以动态拼接查询语句的嘛?或者有其他的方法可以达到同样效果的嘛?