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
|
Hi What would be the correct syntax for constructing a "select" query conditionally on multiple properties? eg. If I've got 5 search fields on my page, any combination of them (or none) can be used to modify the criteria. So I need something along the lines of... if (TaskList.SelectedValue != ""){ QueryExpression += Person.PersonTasks.TaskId == TaskList.SelectedValue; } if (FirstName.Text != ""){ QueryExpression += Person.FirstName.StartsWith(FirstName.Text); } ... etc etc. var personSet = uow.Find(query); I'd really appreciate your guidance on this, thanks, Danzig |
|
|
Core API: QueryExpression query = null; LINQ: var query = unitOfWork.People; The Where clauses get ANDed together. If you need to OR clauses together in LINQ then you'll need to get a bit more involved with expressions -- let us know. Note that it's hard to express through association queries in LINQ. Normally you can work around this by using the "query on the through class" trick but that won't work so well if you're also want to query on person fields. So in this case the core (Find-based) API may give you better service. |
|