Bug #76201 MySQL Linq using .Contains(variable)
Submitted: 6 Mar 2015 22:23 Modified: 9 Apr 2015 7:16
Reporter: Valentin Eidelman Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.9.5 OS:Windows (8.1)
Assigned to: CPU Architecture:Any
Tags: constant, contains, EF6, linq, variable

[6 Mar 2015 22:23] Valentin Eidelman
Description:
When using a EF6 linq query and a .Contains(variable) condition, the query returns an empty set if the variable is not write-protected.

Using .Contains(variable.Trim()) or a constant as a parameter is a work-around.

Previous versions of .Net connector did not have the bug.

VS2013 Pro
EF6.1.2
.Net Connector 6.9.5

I found the same problem being described here:
http://stackoverflow.com/questions/27338108/mysql-linq-using-containsvariable

How to repeat:
db = new discEntities();
IQueryable<agent> ResultIQ;

string lname = "Kah";
ResultIQ = from a in db.agents where a.agent_lastname.Contains(lname.Trim()) select a;
//Returns a Result
foreach (var a in ResultIQ)
{
	Label1.Text += a.agent_lastname + "<BR>";
}
Label1.Text += ResultIQ.Count() + "<BR>";

lname = lname.Trim();
ResultIQ = from a in db.agents where a.agent_lastname.Contains(lname) select a;
//NO Result
foreach (var a in ResultIQ)
{
	Label1.Text += a.agent_lastname + "<BR>";
}
Label1.Text += ResultIQ.Count() + "<BR>";
[9 Mar 2015 7:16] Chiranjeevi Battula
Hello Valentin Eidelman,

Thank you for the bug report.
Issue was fixed in 6.9.6 version. Please try in MySQL Connector/Net 6.9.6.

http://dev.mysql.com/downloads/connector/net/#downloadsandmirrorsites

Thanks,
Chiranjeevi.
[10 Apr 2015 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".