C# search query with linq
c#, linq
Solution
I think you just have it backwards:
mycontext.persons
.Where(t =>
t.Firstname.Contains(search) ||
t.Lastname.Contains(search) ||
t.Description.Contains(search))
.ToList();
Problem
I am trying to make a suitable linq query to accomodate my search functionality. I have a table with the following columns: 'firstname' | 'lastname' | 'description'. with the following data: 'Peter' | 'Mulder' | 'This is a little description.' My 'search' keyword could be something like: "peter" or "a little description". Now if I use the following linq expression in lambda: ``` mycontext.persons .Where(t => search.Contains(t.Firstname) || search.Contains(t.Lastname) || search.Contains(t.Description).Select(p => p) .ToList(); ``` Now I get my result, when I use 'peter', but if I use 'pete' or 'a little description' I get no results. How can I make my linq expression, so it can search through the column data for matches?