Description:
Entity Framework 4 added support for translating the "StartsWith", "EndsWith" and "Contains" methods on the string class to queries which use the "LIKE" function.
To support this new feature, the MySqlProviderManifest class needs to override the new SupportsEscapingLikeArgument method.
Connector/Net v3.6.3 doesn't override this method, so these methods are translated to use the "LOCATE" function instead.
How to repeat:
Create an entity data model for a database, and issue a query which uses StartsWith. For example:
var query = from contact in context.Contacts
where contact.Surname.StartsWith("L")
select new
{
contact.ContactId,
contact.Surname
};
Expected query:
---------------
SELECT
1 AS `C1`,
`Extent1`.`ContactId`,
`Extent1`.`Surname`
FROM
`Contacts` AS `Extent1`
WHERE
`Extent1`.`Surname` LIKE @gp1 ESCAPE '~'
Actual query:
-------------
SELECT
1 AS `C1`,
`Extent1`.`ContactId`,
`Extent1`.`Surname`
FROM
`Contacts` AS `Extent1`
WHERE
LOCATE(@gp1, `Extent1`.`Surname`) = 1
Suggested fix:
Add the following to the .NET 4 version of the MySqlProviderManifest class:
public override bool SupportsEscapingLikeArgument(out char escapeCharacter)
{
escapeCharacter = '~';
return true;
}
Description: Entity Framework 4 added support for translating the "StartsWith", "EndsWith" and "Contains" methods on the string class to queries which use the "LIKE" function. To support this new feature, the MySqlProviderManifest class needs to override the new SupportsEscapingLikeArgument method. Connector/Net v3.6.3 doesn't override this method, so these methods are translated to use the "LOCATE" function instead. How to repeat: Create an entity data model for a database, and issue a query which uses StartsWith. For example: var query = from contact in context.Contacts where contact.Surname.StartsWith("L") select new { contact.ContactId, contact.Surname }; Expected query: --------------- SELECT 1 AS `C1`, `Extent1`.`ContactId`, `Extent1`.`Surname` FROM `Contacts` AS `Extent1` WHERE `Extent1`.`Surname` LIKE @gp1 ESCAPE '~' Actual query: ------------- SELECT 1 AS `C1`, `Extent1`.`ContactId`, `Extent1`.`Surname` FROM `Contacts` AS `Extent1` WHERE LOCATE(@gp1, `Extent1`.`Surname`) = 1 Suggested fix: Add the following to the .NET 4 version of the MySqlProviderManifest class: public override bool SupportsEscapingLikeArgument(out char escapeCharacter) { escapeCharacter = '~'; return true; }