Samurai Ken
Samurai Ken

Reputation: 810

Linq2Entities / Linq2Sql - Comprehensive search

As I read the a similar question about searching SQL I realized I am very curious on how to do the same thing in Linq.

Assume a DB Table with the fields "Title", "Tags" (comma separated) and "Body" (HTML) that has been connected to a Linq2[Entities|Sql] How would you go about searching for a string across those fields.

Yes, I could brute force it but I hope there is something elegant that would suit better.

Upvotes: 2

Views: 219

Answers (1)

Craig Stuntz
Craig Stuntz

Reputation: 126547

The right way to do this is with Full Text Search, such as SQL Server FTS catalogs or Lucene.

The easy way to do it is by downloading Microsoft Dynamic LINQ (Google it), and dynamically building a predicate. I have a demo solution which does just that (with LINQ to Objects, not LINQ to Entities, but the idea is the same) here.

Upvotes: 2

Related Questions