Am I misunderstanding LINQ to SQL .AsEnumerable()?

前端 未结 5 654
遥遥无期
遥遥无期 2020-11-28 07:21

Consider this code:

var query = db.Table
              .Where(t => SomeCondition(t))
              .AsEnumerable();

int recordCount = query.Count();
int          


        
5条回答
  •  暖寄归人
    2020-11-28 08:03

    Yes. All that AsEnumerable will do is cause the Count, Sum, and Average functions to be executed client-side (in other words, it will bring back the entire result set to the client, then the client will perform those aggregates instead of creating COUNT() SUM() and AVG() statements in SQL).

提交回复
热议问题