I want to make a simple request with several conditions
I use OrmLite to display an entity object.
Now I want to find the object in my table.
Suppose I have a Person object that displays the PERSON table, what I want to do is initialize the object with some parameters and do a search.
Assume the function searchPerson(Person oPerson)
If I pass an OPerson object like this
Id = null
Name = John
Age = null
Sex = male
Can I write a request to achieve this? Something like this pseudo code
pers = (from p in db.Table<Person>()
where (if OPerson.Id !=null) p.Id==OPerson.Id}
AND {(if OPerson.Name !=null) p.Name.Contains(OPerson.Name)}
AND {(if condition) where-contion}
select p).ToList();
I know that I can make several requests this way
list=PersonDao.queryBuilder().where().eq("name",OPerson.name).and().eq("sex",OPerson.sex").query();
but I also want to check if a value exists
source
share