投影元素的位置不包括查询中的位置

时间:2018-04-25 13:25:28

标签: entity-framework .net-core

我有以下情况:

foos.Select(f => new Bar { 
    A = f.A, 
    B = f.B, 
    C = f.C == null ? "Yes" : "No",
    D = 10,
    E = f.SubObject.Value
})
.Where(b => b.C == "Yes")

现在看来这会产生以下内容:

SELECT 
    [f0].[A],
    [f0].[B],
    CASE WHEN [f0].[C] IS NULL N'Yes' ELSE N'No' END AS [C],
    10 AS [D],
    [f.SubObject0].[Value] AS [E]
FROM [foos] AS [f0]
LEFT JOIN [SubObjects] AS [f.SubObject0]
   ON [f0].[ObjectID] = [f.SubObject0].[ObjectId]

但它不包括where子句。有没有办法强制它在那里?现在看到它会在执行where之前抓取foos表中的所有实体,其中ofc非常慢。

0 个答案:

没有答案