Когда я запускаю следующий запрос linq (asp. net MVC 5):
var source = from a in ControllerFactory.AuthRepository.Database.Announcements
let d = date
let start = a.start
where (!useStartDateFilter || start <= d) && a.end > d
orderby start
select a;
var items = await source.Skip(CurrentPage * PageSize).Take(PageSize).ToListAsync();
Сгенерированный запрос SQL:
SELECT
[Project1].[id] AS [id],
[Project1].[start] AS [start],
[Project1].[end] AS [end],
[Project1].[json_localized_annoucement] AS [json_localized_annoucement],
[Project1].[json_localized_link] AS [json_localized_link]
FROM ( SELECT
[Extent1].[id] AS [id],
[Extent1].[start] AS [start],
[Extent1].[end] AS [end],
[Extent1].[json_localized_annoucement] AS [json_localized_annoucement],
[Extent1].[json_localized_link] AS [json_localized_link]
FROM [dbo].[Announcements] AS [Extent1]
WHERE ((@p__linq__0 <> 1) OR ([Extent1].[start] <= @p__linq__1)) AND ([Extent1].[end] > @p__linq__1)
) AS [Project1]
ORDER BY row_number() OVER (ORDER BY [Project1].[start] ASC)
OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY
Может кто-нибудь объяснить, почему он генерирует часть [Project1]?
Можно ли этого избежать? Может быть, эта проекция не влияет на производительность запроса?