#
baldec
Hello again dear friends. Having finally managed to get the NHibernate I have now run into another thing that I assume can be done in a smoother way.
I have 4 checkboxes symbolising some fields in the DB. And I have a text field with the search criteria.
I want to search on the fields in the db if the checkbox is checked.
Currently the code is as follows
And that works just fine if all checkboxes are filled. But if the checkbox aint filled I want to return a false value for the Expression.Like part.
Though I can't for the love of god figure out the correct way to make the criteria match. Currently I solved the issue with
Which ofc works as long as the guest doesn't manage to enter the jumbled string. Though I am guessing that there is some basic handling of this that I have missed.
Anyone care to enlighten me? :)
I have 4 checkboxes symbolising some fields in the DB. And I have a text field with the search criteria.
I want to search on the fields in the db if the checkbox is checked.
Currently the code is as follows
criteria.Add
(
Expression.Or
(
Expression.Or
(
Expression.Like("Name", nameCriteria, MatchMode.Anywhere),
Expression.Like("City", cityCriteria, MatchMode.Anywhere)
),
Expression.Or
(
Expression.Like("Address", addressCriteria, MatchMode.Anywhere),
Expression.Like("Phone", phoneCriteria, MatchMode.Anywhere)
)
)
);And that works just fine if all checkboxes are filled. But if the checkbox aint filled I want to return a false value for the Expression.Like part.
Though I can't for the love of god figure out the correct way to make the criteria match. Currently I solved the issue with
nameCriteria = ? searchCriteria : "xxyyzz";Which ofc works as long as the guest doesn't manage to enter the jumbled string. Though I am guessing that there is some basic handling of this that I have missed.
Anyone care to enlighten me? :)