Page 1 of 1
Method 'Boolean Equals(System.String, System.String, System.StringComparison)' is not supported for execution as SQL.
Posted: Wed 28 Aug 2013 14:56
by emp51302
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
Re: Method 'Boolean Equals(System.String, System.String, System.StringComparison)' is not supported for execution as SQL.
Posted: Mon 02 Sep 2013 16:24
by Shalex
This method is currently not supported. We will post here when the corresponding support is implemented.
Re: Method 'Boolean Equals(System.String, System.String, System.StringComparison)' is not supported for execution as SQL.
Posted: Tue 03 Sep 2013 14:37
by Shalex
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()));
Re: Method 'Boolean Equals(System.String, System.String, System.StringComparison)' is not supported for execution as SQL.
Posted: Tue 03 Sep 2013 15:43
by emp51302
Shalex - Already doing that, thanks! When will the requested functionality be available?
Thanks
Re: Method 'Boolean Equals(System.String, System.String, System.StringComparison)' is not supported for execution as SQL.
Posted: Fri 06 Sep 2013 14:50
by Shalex
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]