Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search by joining properties. #49

Open
kadirgedik opened this issue Apr 12, 2023 · 1 comment
Open

Search by joining properties. #49

kadirgedik opened this issue Apr 12, 2023 · 1 comment

Comments

@kadirgedik
Copy link

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.

@Crusader2010
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants