Bug #75137 .Net Connector 6.9.5 does not pass in variable argument for .Contains extension
Submitted: 7 Dec 2014 2:01 Modified: 8 Dec 2014 6:47
Reporter: Phil Cazella Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:6.9.5 OS:Microsoft Windows
Assigned to: CPU Architecture:Any
Tags: EF6 LINQ NET

[7 Dec 2014 2:01] Phil Cazella
Description:
http://stackoverflow.com/questions/27338108/mysql-linq-using-containsvariable

Setup info:

VS2013 / C#
EF6
MySQL database
.Net Connector 6.9.5

I'm trying to create a method that returns a collection of Account records using a partial name as the search criteria. If I hard code a string value using the IQueryable .Contains() extension method, it returns data. However, when I attempt to use a variable no data is returned.

Public class Test() {

MyEntities db = new MyEntities();

//Works....but the search criteria is hard coded.
  public IQueryable<Account> WorksButValueHardCoded() {

    return (from a in db.Accounts
           where a.accountname.Contains("Test")
           select a);
  }

//Does not return anything
  public IQueryable<Account> DoesNotReturnAnyData() {

    //Obviously I would use a parameter, but even this test fails
    string searchText = "Test";  

    return (from a in db.Accounts
           where a.accountname.Contains(searchText)
           select a);
  }
}

How to repeat:
Create a context

query that context and pass a variable to the the .Contains extension method for a VARCHAR field.

Suggested fix:
I can see in the LINQ generated SQL used the LIKE operator, but I don't understand how the variable is injected to suggest a fix.

SELECT
`Extent1`.`accountid`, 
`Extent1`.`accountname`
FROM `account` AS `Extent1`
WHERE `Extent1`.`accountname` LIKE '%p__linq__0%'
[8 Dec 2014 6:47] Chiranjeevi Battula
Hello Phil Cazella,

Thank you for the bug report.
This is duplicate of Bug #74918.

Thanks,
Chiranjeevi.