Skip to Content

HANA case insensitive with Entity Framework

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 ?

Add a comment
10|10000 characters needed characters exceeded

Related questions

0 Answers

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.