DB2 - Problembeschreibung
Problem IC77827 | Status: Geschlossen |
LINQ EF QUERIES THAT USE CONTAINS, STARTSWITH OR ENDSWITH FUNCTIONS GENERATE INVALID SQL FOR IDS ON .NET 4.0 | |
Produkt: | |
DB2 CONNECT / DB2CONNCT / 970 - DB2 | |
Problembeschreibung: | |
When Contains, StartsWith or EndsWith is used in the Where clause of LINQ query, the .NET 4.0 runtime converts it to LIKE expression. Moreover, when a string variable, instead of a contant, is used as input to one of those functions, the generated LIKE expression contains an ESCAPE clause with the default escape character of '\'. Since '\' is a constant expression, the EF providers' SQL Generator converts it to a CAST expression of CAST('\' as nvarchar(1)). However, the IDS servers' ESCAPE clause doesn't support cast expressions, thus, a syntax error is generated for this SQL. From the customer perspective this means that while the folllwing LINQ query works fine: var plans = model.Plans.Where(p => p.plan.StartsWith("AND")).Select(p => new{p.plan,p.id}).ToList(); The same query that uses a variable instead of constant fails: var startsWith = "AND"; var plans = model.Plans.Where(p => p.plan.StartsWith(startsWith)).Select(p => new{p.plan,p.id}).ToList(); with the following error message: "ERROR 42000 IBMIDS/UNIX64 A syntax error has occurred." | |
Problem-Zusammenfassung: | |
**************************************************************** * USERS AFFECTED: * * .NET 4.0 applications using EF 4.0 against IDS server * **************************************************************** * PROBLEM DESCRIPTION: * * When Contains, StartsWith or EndsWith is used in the Where * * * * clause of LINQ query, the .NET 4.0 runtime converts it to * * LIKE * * expression. Moreover, when a string variable, instead of a * * * * contant, is used as input to one of those functions, the * * * * generated LIKE expression contains an ESCAPE clause with the * * * * default escape character of '\'. Since '\' is a constant * * * * expression, the EF providers' SQL Generator converts it to a * * * * CAST expression of CAST('\' as nvarchar(1)). However, the * * IDS * * servers' ESCAPE clause doesn't support cast expressions, * * thus, a * * syntax error is generated for this SQL. * * * * From the customer perspective this means that while the * * * * folllwing LINQ query works fine: * * * * * * * * var plans = model.Plans.Where(p => * * * * p.plan.StartsWith("AND")).Select(p => * * * * new{p.plan,p.id}).ToList(); * * * * * * * * The same query that uses a variable instead of constant * * fails: * * * * * * var startsWith = "AND"; * * * * var plans = model.Plans.Where(p => * * * * p.plan.StartsWith(startsWith)).Select(p => * * * * new{p.plan,p.id}).ToList(); * * * * * * * * with the following error message: "ERROR 42000 * * IBMIDS/UNIX64 A * * syntax error has occurred." * **************************************************************** * RECOMMENDATION: * * Upgrade the client to V9.7 FP5. * **************************************************************** | |
Local-Fix: | |
verfügbare FixPacks: | |
DB2 Version 9.7 Fix Pack 5 for Linux, UNIX, and Windows | |
Lösung | |
Workaround | |
keiner bekannt / siehe Local-Fix | |
Weitere Daten | |
Datum - Problem gemeldet : Datum - Problem geschlossen : Datum - der letzten Änderung: | 28.07.2011 07.12.2011 07.12.2011 |
Problem behoben ab folgender Versionen (IBM BugInfos) | |
9.7.FP5 | |
Problem behoben lt. FixList in der Version | |
9.7.0.5 |