This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
We are trying to build a search tool and the searchable fields are going to vary. Is it possible to conditionally concatenate a queries where clause joining the conditions with an or operator rather than the and operator? This code is close but builds the condition using and. How can I build the query by joining the conditions with an or? var results= from c in uow.Clients where c.Lastnmae.StartsWith = "al" select c; if (!string.IsNullOrEmpty(searchCriteria.StreetAddress)) results = results.Where(c => c.StreetAddress.StartsWith(searchCriteria.StreetAddress)); if (!string.IsNullOrEmpty(searchCriteria.FirstName)) results = results.Where(c => p.Firstname.StartsWith(searchCriteria.FirstName)); Thanks |
|
|
This is how I'm doing it:
There are all sorts of expressions you can build up this matter, I'm not sure how to do this using LINQ. |
|
|
Thanks for that:) I'll give it a try |
|
|
Thanks for that:) I'll give it a try |
|