If you need to search on four fields, you can continue to expand your OR conditions to include the additional fields.
var result = LogData.Where(x => ( searchText == "" || x.Location.Contains(searchText) || x.Messsage.Contains(searchText) || x.Sender.Contains(searchText) || x.AccountName.Contains(searchText)) );
As Charlieface mentioned, you can potentially optimize this a bit by treating
searchText == "" as an early exit condition and return your collection without a where clause.
var result = searchText == "" ? LogData : LogData.Where(x => ( x.Location.Contains(searchText) || x.Messsage.Contains(searchText) || x.Sender.Contains(searchText) || x.AccountName.Contains(searchText)) );
- How to check search text contains in any field
- Entity Framework, Code First and Full Text Search
- How to check if any word in my List<string> contains in text
- Check if values of Dictionary contains an element with certain field value
- LINQ query to check if array contains search term
- Check if field contains any item from collection in LinqToSql
- How to search for empty strings in a text field with Entity Framework?
- using linq to find if a text field contains any string in a list
- Check if text contains any string item from list of string c# linq
- How to search a text contains or not in particular column that contain Json object using linq
- Using LINQ how would I check if a XML row contains a field and if it does check a different field on the same row for a value
- LINQ expression to check if field contains string
- Check if list contains element that contains a string and get that element
- Check if one IEnumerable contains all elements of another IEnumerable
- How do I find the text within a div in the source of a web page using C#
- How to check list A contains any value from list B?
- Is it possible to use Full Text Search (FTS) with LINQ?
- Check if list contains item from other list in EntityFramework
- The source contains no DataRows
- LINQ: Entity string field contains any of an array of strings
- Sequence contains no elements error but I want to check for null
- Full Text Search in Linq
- Check if a string within a list contains a specific string with Linq
- How to use Linq to check if a list of strings contains any string in a list
- check whether a List<string> contains an element in another List<string> using LINQ
- Check if a string contains only letters, digits and underscores
- Check if a String value contains any number by using Lambda Expression
- Check if a string contains particular characters in any order
- Check if one list contains any elements from another
- Check if a list contains all of another lists items when comparing on one property
- c# linq nested "conditional/composite" grouping
- C#: Merge Datarows in the datatable
- How to concatenate string with decimal?
- Simple LINQ select (using Entity Framework) does not return values
- Error connecting to SQL from WCF Using LINQ - but affects only one server
- Retrieve ID from database in mvc
- EntityFramework6 - Error 42703: column Extent1... not found
- Problem with sorting objects
- One to Many LINQ query - Assembly does not have definition for SELECT
- counting numbers in array above a certain level with C#
- What should be the return type when writing Linq query for selecting specific columns?
- Generic All Controls Method
- how to perform sum on average on distinct different then the group field
- C# LInq Subquery Issue
- Case statement in Linq for a nullable datetime field
- Linq to SQL Group by and Sum in Select
- LINQ error: The null value cannot be assigned to a member with type System.Int32 which is a non-nullable value type
- How to add to a dictionary when there may be duplicate keys?
- How to fill object with list using EF
- LINQ Where clause throws casting exception from string to Guid even though comparison only contains Guids