For example, the following query used to produce an exception:
var chef = new Chef { ID = 23, FirstName = "Hugo", Name = "Heinrich" }; CheckQuery ( from s in Cooks where s.Assistants.Contains (chef) select s);
This has been changed - the result operator now checks that the item expression is assignable to the item type of the sequence, not equal to it.
For example, for an expression such as c.ContactName.IndexOf (" "), re-linq will generate the following SQL:
CASE WHEN (LEN(@1) = 0) THEN 0 ELSE (CHARINDEX(@2, [t0].[ContactName]) - 1) END (@1 = " ") (@2 = " ")
(The CASE is required because CHARINDEX will return -1 for empty strings, whereas .NET will return 0.)
The problem is that LEN will not work correctly with trailing spaces - it ignores them.
The fix is to append a single character to the string and subtract 1 from the result. Instead of LEN(@1), use LEN(@1 + '#') - 1.