SIMILAR TO pattern matching

SIMILAR TO pattern matching

Postby yozey » Tue 04 Sep 2012 23:36

Is there be support in Linq to PostgreSQL for their SIMILAR TO pattern matching operator?
yozey
 
Posts: 32
Joined: Sat 17 Jan 2009 14:41

Re: SIMILAR TO pattern matching

Postby 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/Devart.Data.Linq~Devart.Data.Linq.DataContext~ExecuteQuery.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.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: SIMILAR TO pattern matching

Postby yozey » Wed 05 Sep 2012 13:32

Thanks for your reply. I will use the ExecuteQuery method.
yozey
 
Posts: 32
Joined: Sat 17 Jan 2009 14:41


Return to dotConnect for PostgreSQL