看起来我发现了一个错误:
我有桌子
Users 1 <---> * Customers
现在我想获得Users
的特定类型,其Customers
包含Name
或Surname
列中的一些文字:
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__0
和p__linq__1
更改为例如a
我看到了一些结果