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

2 posts, 0 answers
  1. Pavel
    Pavel avatar
    5 posts
    Member since:
    Oct 2013

    Posted 07 Oct 2016 Link to this post

    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 

  2. Pavel
    Pavel avatar
    5 posts
    Member since:
    Oct 2013

    Posted 10 Apr Link to this post

    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.
Back to Top