on ‎2019 Feb 12 5:45 PM
I try to use the Entity Framework to create a query that is case-insensitive.
The query should look like :
SELECT TOP 10 * FROM "SBODEMODE"."ORDR" WHERE LOWER("CardName") LIKE '%gmbh%'
So my first try was:
var querySimple = (
from ORDR in db.ORDDs
where ORDR.CardName.Contains("gmbh")
select ORDR
).Take(10);
So far so good.
The generated query looks like:
SELECT TOP 10
"Extent1"."DocEntry" AS "DocEntry",
"Extent1"."DocNum" AS "DocNum",
"Extent1"."CardCode" AS "CardCode",
"Extent1"."CardName" AS "CardName",
"Extent1"."DocTotal" AS "DocTotal"
FROM "SBODEMODE"."ORDR" AS "Extent1"
WHERE ("Extent1"."CardName" LIKE N'%gmbh%')
ORDER BY 'a'
But the query is not case insenstive.
So my next try was to use .ToLower() function:
var querySimple = (
from ORDR in db.ORDDs
where ORDR.CardName.ToLower().Contains("gmbh".ToLower())
select ORDR
).Take(10);
Now the generated query looks like:
SELECT TOP 10
"Extent1"."DocEntry" AS "DocEntry",
"Extent1"."DocNum" AS "DocNum",
"Extent1"."CardCode" AS "CardCode",
"Extent1"."CardName" AS "CardName",
"Extent1"."DocTotal" AS "DocTotal"
FROM "SBODEMODE"."ORDR" AS "Extent1"
WHERE (CHARINDEX(LOWER(N'gmbh'), LOWER("Extent1"."CardName"))) > 0
ORDER BY 'a'
The query is not executable in this way.
-> SAP DBTech JDBC: [328]: invalid name of function or procedure: CHARINDEX: line 8 col 8 (at pos 245)
HANA version is 1.00.122
Driver version is 2.3.130.0
Entity Framework verison 6.2
Maybe someone has solved a similar problem or has an idea how to solve the problem ?
Request clarification before answering.
| User | Count |
|---|---|
| 9 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.