This is a migrated thread and some comments may be shown as answers.

Why operations like where (skip,take) working in memory after select new?

1 Answer 49 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Pavel
Top achievements
Rank 1
Pavel asked on 07 Oct 2016, 10:13 AM

Lets say i have following query

    var items = db.Peoples.Select(x => new {x.Id, x.Name})
    .Where(x => x.Name != null).Skip(5).Take(10).ToList();
and query that executing in database is look like

    select Id, Name from Peoples

so the question is why where clause, skip, take, working in memory?

If i use entity framework in same situation, it generates correct query

SELECT 
    [Project1].[C1] AS [C1], 
    [Project1].[Id] AS [Id], 
    [Project1].[Name] AS [Name]
    FROM ( SELECT 
        [Extent1].[Id] AS [Id], 
        [Extent1].[Name] AS [Name], 
        1 AS [C1]
        FROM [dbo].[People] AS [Extent1]
        WHERE [Extent1].[Name] IS NOT NULL
    )  AS [Project1]
    ORDER BY [Project1].[Name] ASC
    OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY 

1 Answer, 1 is accepted

Sort by
0
Pavel
Top achievements
Rank 1
answered on 10 Apr 2017, 10:56 AM
This is an important question, it would be nice if someone answered.
I see no reason to continue using this orm if the situation on this issue does not change.
Tags
General Discussions
Asked by
Pavel
Top achievements
Rank 1
Answers by
Pavel
Top achievements
Rank 1
Share this question
or