Skip to content

$inlinecount in EntityFramework doesn't generate a sql count query #35

@diegomesata

Description

@diegomesata

Hello, LinqToQuerystring is a great tool. I tried to use microsoft webapi odata in my web api controllers but $inlinecount just doesn't work out of the box, you have to do a lot of hacks in order to make it works, but LinqToQuerystring solved my problems!

I was debugging the entity framework's sql querys and I found that $inlinecount doesn't generate a sql count query. I think all data are being loaded in memory and after that are being counted (too much memory!).

[6880] SELECT
[6880] [Extent1].[LogId] AS [LogId],
[6880] [Extent1].[Time] AS [Time],
[6880] [Extent1].[Event] AS [Event],
[6880] [Extent1].[UserId] AS [UserId],
[6880] [Extent1].[Message] AS [Message],
[6880] [Extent1].[IP] AS [IP]
[6880] FROM [dbo].[Log] AS [Extent1]
[6880] ORDER BY [Extent1].[LogId] DESC

I think the call should be:

SELECT
[GroupBy1].[A1] AS [C1]
FROM ( SELECT
COUNT(1) AS [A1]
FROM [dbo].[Log] AS [Extent1]
ORDER BY [Extent1].[LogId] DESC
) AS [GroupBy1]

Could you check it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions