Behnam Esmaili Behnam Esmaili - 3 months ago 9
C# Question

Is Orchard contentManager `List()` identical to Linq Tolist()?

The question is, when I call

ToList()
in a
Linq
(to Sql) query it fetches all the records from db and brings them into memory.and I wonder if
List()
method of orchard ContentManager has same effect ?

Thanks in advance.

Answer

Yes. List() returns:

_query.Slice(0, 0).AsPart<T>()

Slice(0, 0) returns the whole result set as a read-only collection, and has the effect of executing the query and bringing the results into memory. AsPart<T>() presents the list of content items as a list of parts of type T.

Comments