Skip to content

Instantly share code, notes, and snippets.

@JamesGould123
Created December 23, 2014 20:42
Show Gist options
  • Save JamesGould123/e3d7dd50132de72c3c38 to your computer and use it in GitHub Desktop.
Save JamesGould123/e3d7dd50132de72c3c38 to your computer and use it in GitHub Desktop.
LINQ to Entities Contains bug
string queryStr = "AB7";
var viewModel5 = (from n in db.TableName
where n.TableCol.Contains("AB7")
select n.TableCol); //running ToList with this returns 35 results
//viewModel5 = {SELECT
//`Extent1`.`TableCol`
//FROM `TableName` AS `Extent1`
//WHERE `Extent1`.`TableCol` LIKE '%AB7%'}
var viewModel6 = (from n in db.TableName
where n.TableCol.Contains(queryStr)
select n.TableCol); //running ToList with this returns 0 results
//viewModel6 = {SELECT
//`Extent1`.`TableCol`
//FROM `TableName` AS `Extent1`
//WHERE `Extent1`.`TableCol` LIKE '%p__linq__0%'}
var strEqualsStr = "AB7" == queryStr; //true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment