Page 1 of 1

Query with Underscore Character

Posted: Thu 10 Dec 2009 09:27
by cp_Volker
Hello,

I use dotConnect for Oracle V 5.25.49 together with the Entity Framework and an Oracle 10g database and I want to query for database entries which contain an underscore character. For this I use following statement:

var l_Query = l_EntitiesContext.CUSTOMER.Where(item => item.LASTNAME.Contains("_"));

This statement returns the whole dataset of the CUSTOMER table independent from the LASTNAME entry because the underscore character is interpreted as a wildcard for a single character.

Is there any possibility to 'escape' the underscore character to tell the provider respectively the database not to use it as wildcard ?
Thank you for your help.

Best Regards,
Volker

Posted: Fri 11 Dec 2009 12:53
by AndreyR
There is no way to do this using LINQ to Entities. Try Entity SQL like the following:

Code: Select all

select value item from Customers as item where item.Lastname like '%!_%' escape '!'