Method 'Boolean Equals(System.String, System.String, System.StringComparison)' is not supported for execution as SQL.

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
emp51302
Posts: 46
Joined: Fri 19 Aug 2011 20:57

Method 'Boolean Equals(System.String, System.String, System.StringComparison)' is not supported for execution as SQL.

Post by emp51302 » Wed 28 Aug 2013 14:56

Hi - I am trying to write a Linq query which looks like...

Code: Select all

MyDictionary word = bldc.MyDictionarys.FirstOrDefault(w => w.DicId == MyDicId && String.Equals(w.Word.Trim(), row[0].ToString().Trim(), StringComparison.OrdinalIgnoreCase));
But unfortunately I am getting
"Method 'Boolean Equals(System.String, System.String, System.StringComparison)' is not supported for execution as SQL."
Is there any other way to do a string compare in Linq for dotConnect.

Would appreciate it.

Thanks

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Method 'Boolean Equals(System.String, System.String, System.StringComparison)' is not supported for execution as SQL.

Post by Shalex » Mon 02 Sep 2013 16:24

This method is currently not supported. We will post here when the corresponding support is implemented.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Method 'Boolean Equals(System.String, System.String, System.StringComparison)' is not supported for execution as SQL.

Post by Shalex » Tue 03 Sep 2013 14:37

As a temporary workaround, please use the following query:

Code: Select all

MyDictionary word = bldc.MyDictionarys.FirstOrDefault(w => w.DicId == MyDicId && (w.Word.Trim().ToLower() == row[0].ToString().Trim().ToLower()));

emp51302
Posts: 46
Joined: Fri 19 Aug 2011 20:57

Re: Method 'Boolean Equals(System.String, System.String, System.StringComparison)' is not supported for execution as SQL.

Post by emp51302 » Tue 03 Sep 2013 15:43

Shalex - Already doing that, thanks! When will the requested functionality be available?

Thanks

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Method 'Boolean Equals(System.String, System.String, System.StringComparison)' is not supported for execution as SQL.

Post by Shalex » Fri 06 Sep 2013 14:50

Tell us your opinion: what SQL should be generated for MySQL by String.Equals(stringExpression1, stringExpression2, stringComparisonValue) for different values of StringComparison?

We consider the most flexible way to do this with SQL-construction like

Code: Select all

stringExpression1 = stringExpression2 COLLATE x
where x is latin1_bin or utf16_bin or utf8_bin or any other collation.

So the Collate(string value, string collationName) method of the SqlMethods class is implemented in the new (7.8) version of dotConnect for MySQL.

An example of its usage:

Code: Select all

var a = context.Depts.FirstOrDefault<Dept>(w => w.DEPTNO == myDEPTNO && SqlMethods.Collate(w.DNAME.Trim(), "utf8_bin") == research.ToString().Trim());
The corresponding SQL would be:

Code: Select all

SELECT t1.DEPTNO, t1.DNAME, t1.LOC
FROM alexsh.Dept t1
WHERE (t1.DEPTNO = :p0) AND (TRIM(t1.DNAME) COLLATE 'utf8_bin' = :p1) LIMIT 1
-- p0: Input Int (Size = 0; DbType = Int32) [10]
-- p1: Input VarChar (Size = 8; DbType = AnsiString) [RESEARCH]

Post Reply