In a Konamiman sentence, I checked the log to see if SQL was running. Here (a sketched example) that I received.
The first call is made:
SELECT [t0].[ID], [t0].[Name] FROM [dbo].[MyEntity] AS [t0]
This makes sense since filtering is done on the client side, so we need to query all rows.
The second call is made:
SELECT COUNT(*) AS [value] FROM [dbo].[MyEntity] AS [t0] WHERE [t0].[Name] LIKE @p0 ESCAPE '~'
So John Skeet was on the right track; I have a problem because I have a tilde in the data / request type. This causes LINQ-to-SQL to put it as an escape character, and therefore it is not used in the search. This MSDN thread does a decent job explaining why ; this is apparently a bug in LINQ to SQL code.
The suggested workaround is to use the LINQ SQLMethods.Like () method to change the escape character from "~", for example:
var direct = MyDataContext.MyEntities.Where(entity => SQLMethods.Like(entity.Name, "~Test: My Test String%", "!");
This works, but unfortunately it is a LINQ-to-SQL solution. If you try it in the LINQ-to-Object version, you will get this error:
System.NotSupportedException : Method 'Boolean Like(System.String, System.String, Char)' cannot be used on the client; it is only for translation to SQL.
The same thing happens when using AsEnumerable (), as suggested by Jon Skeet.
I tried wrapping my StartsWith call in a method and using StartsWith with StringComparisonOption, but they do not work on the LINQ-to-SQL side because they are not SQL-translatable. (And thus, my previous assumption about the Where () method was wrong).
So: it seems (until this error has been fixed) you will not have a search function that works with tilde characters and is agnostically related to the basic LINQ flavor. (If there is a way, be sure to post it).