Try NinjaNye.SearchExtensions .
It will allow you to use the following syntax:
var result = GetAll().Search("search", x => x.Username, x => x.Firstname, x => x.Lastname) .ToList();
When used with sql, this will result in the following:
SELECT [Extent1].[Id] AS [Id], [Extent1].[Username] AS [Username], [Extent1].[Firstname] AS [Firstname], [Extent1].[Lastname] AS [Lastname] FROM [dbo].[Users] AS [Extent1] WHERE ([Extent1].[Username] LIKE N'%search%') OR ([Extent1].[Firstname] LIKE N'%search%') OR ([Extent1].[Lastname] LIKE N'%search%')
... means that all work is done in the data source, not in memory
For the source code, see the github page:
https://github.com/ninjanye/SearchExtensions
Ninja nye
source share