I'm looking for rules of thumb for calling ToList/ToArray/MemoizeAll(Rx) on IEnumerables, as opposed to returning the query itself when returning IEnumerable of something.

Often I find that it is better to just return the query and let the caller decide whether a list is needed or not, but sometimes it can come back and bite you in the rear due to the lazy nature of linq.

I want to collect guidelines such as:

Call ToList if:

  • you create new objects (eg. in a select)
  • you have side effects in your query

Otherwise, return the query

Edit
Report