+1  A: 

It seems you should be using f.ErrorMessage.Contains(err.ErrorMessage) - linq to sql should then convert this to WHERE ErrorFilter.ErrorMessage LIKE %err.ErrorMessage%. The problem with the way you have it is that the generated SQL would need a dynamic string to match in the where clause, and hence could only be filtered on the client.

Incidently, the var query = from filter in DataContext.ErrorFilters select filter; line is not required and you can just do:

var filters = DataContext.ErrorFilters.Where(f => f.ErrorMessage.Contains(err.ErrorMessage)).ToList();

EDIT:

Ok I see what you're trying to do now, but I'm not sure if this is possible in linq2sql. You could create a stored procedure and add that to your datacontext and do the mapping from the output to a sequence of ErrorFilter objects:

create procedure GetMatchingFilters @message varchar(500)
as
begin
    select *
    from ErrorFilter
    where @message LIKE '%'+ErrorMessage+'%'
end

Then in your datacontext you can do:

DataContext
    .GetMatchingFilters(err.ErrorMessage)
    .Select(result => new ErrorFilter {...})
    .ToList();
Lee
The problem with that is that it would be very difficult to filter out based on the ErrorMessage. The ErrorMessage is usually very long, and you should be able to create a filter by just typing "timeout expired".Using your method, the user would have to have the ErrorMessage for the filter be exactly the same as the ErrorMessage for the error.
No, it should work as you described, the query will be something like SELECT * FROM ErrorFilters WHERE ErrorMessage LIKE %someString%. Unless I've misunderstood the problem...
Lee
Invert `f.ErrorMessage.Contains(err.ErrorMessage))` to `err.ErrorMessage.Contains(f.ErrorMessage))`
Alex Bagnolini
Lee: I think you may have misunderstood. Say I get an error with the message "System.Data.SqlClient.SqlException: Timeout expired.", and I have a filter with the message "timeout expired". Using your solution, it will check to see if the string "timeout expired" contains the long error message from the initial error. It should be checking to see if the long error message contains the string "timeout expired". Does that make sense? Alex: That's what I already have.
Thanks for the update, Lee. It looks like that will be the route I'll have to take, thanks for all your help.