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

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

Postby 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
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.

Postby Shalex » Mon 02 Sep 2013 16:24

This method is currently not supported. We will post here when the corresponding support is implemented.
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44

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

Postby 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()));
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44

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

Postby emp51302 » Tue 03 Sep 2013 15:43

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

Thanks
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.

Postby 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]
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for MySQL