Force Linq to not delay execution

前端 未结 4 2050
礼貌的吻别
礼貌的吻别 2021-02-12 15:12

In fact, this is the same question as this post:

How can I make sure my LINQ queries execute when called in my DAL, not in a delayed fashion?

But since he didn\'

4条回答
  •  名媛妹妹
    2021-02-12 16:10

    Can you explain more why .ToList is not acceptable? You mentioned boxing and unboxing but those are completely unrelated topics.

    Part of forcing a LINQ query to complete on demand necessitates storing the results. Otherwise in order to see the results again, you'd have to repprocess the query. .ToList efficiently achieves this by storing the elements in a List.

    It's possible to store the elements in virtually any other collection style data structure with various trade offs that may suit your needs better.

提交回复
热议问题