Query with Underscore Character

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
cp_Volker
Posts: 3
Joined: Thu 10 Dec 2009 08:14

Query with Underscore Character

Post by cp_Volker » Thu 10 Dec 2009 09:27

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

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Fri 11 Dec 2009 12:53

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 '!'

Post Reply