SearchExtensions
SearchExtensions copied to clipboard
Search by joining properties.
What i want to do;
query.Search(x => string.Join(" ", x.Property1, x.Property2)).Containing("searchTerm");
This method does not work well. is there another way?
thanks.
Have you tried this?
[...]
query.Select(x => new { JoinedItem = x.Property1 + " " + x.Property2 })
.Search(y => y.JoinedItem).Containing("searchTerm")
[...]
Not sure EF knows about string.Join(), but it's an easy concatenation. There are other ways to do it too, the worst being to actually get the results into memory and using string.Join(). Another way is to have a computed column on that database table, that holds exactly the value you want => Property1 + " " + Property2. Then, you use Search() on this column.