C#MySQL Connector LIKE运算符无法正常工作

时间:2015-01-27 12:56:07

标签: c# mysql

看起来我发现了一个错误:

我有桌子

Users 1 <---> * Customers

现在我想获得Users的特定类型,其Customers包含NameSurname列中的一些文字:

var result = (from x in Query()
              where x.UserTypeID == 123
                   &&
                   (
                      x.Customer.Name.Contains(myString)
                       ||
                      x.Customer.Surname.Contains(myString)
                   )
              select x)
             .ToList();

我自己运行该代码生成的SQL查询,我看到了一些行存在。但是,编译器返回一个空列表。为什么?

这是生成的SQL查询

SELECT
    `Filter1`.`ID`, 
    `Filter1`.`UserTypeID`, 
    `Filter1`.`CustomerID`
FROM (
    SELECT
    `UL`.`ID`, 
    `UL`.`UserTypeID`, 
    `UL`.`CustomerID`
    FROM `Users` AS `UL`
    LEFT OUTER JOIN `Customer` AS `CUST` ON `UL`.`CustomerID` = `CUST`.`ID`
    WHERE `UL`.`UserTypeID` = 123
) AS `Filter1`

LEFT OUTER JOIN `Customer` AS `Extent3` ON `Filter1`.`CustomerID` = `Extent3`.`ID`
WHERE (`Filter1`.`Name` LIKE '%p__linq__0%') OR (`Extent3`.`Surname` LIKE '%p__linq__1%')

我将p__linq__0p__linq__1更改为例如a我看到了一些结果

0 个答案:

没有答案