SIMILAR TO pattern matching

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
yozey
Posts: 32
Joined: Sat 17 Jan 2009 14:41

SIMILAR TO pattern matching

Post by yozey » Tue 04 Sep 2012 23:36

Is there be support in Linq to PostgreSQL for their SIMILAR TO pattern matching operator?

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: SIMILAR TO pattern matching

Post by MariiaI » Wed 05 Sep 2012 10:46

You could use SqlMethods.Like method, which is translated into SQL command 'LIKE'. The 'SIMILAR TO' operator is not supported, because there are no methods, that could be translated into it. Thus, if you are using any complex regular expressions, you can only write commands manually and perform them via the ExecuteQuery() method (http://www.devart.com/linqconnect/docs/ ... Query.html).

Example of using SqlMethods.Like:

Code: Select all

YourDataContext context = new YourDataContext();
var query = from c in context.Depts where Devart.Data.Linq.SqlMethods.Like(c.Dname, "SALES") select c;
Please tell us if this helps.

yozey
Posts: 32
Joined: Sat 17 Jan 2009 14:41

Re: SIMILAR TO pattern matching

Post by yozey » Wed 05 Sep 2012 13:32

Thanks for your reply. I will use the ExecuteQuery method.

Post Reply