I am looking for best practices for creating collections made from anonymous types.
There are several approaches - this one and most answers on this thread assume th
this one and most answers on this thread assume that the whole anonymous collection can be constructed in one statement.
Yes, you normally create a collection of anonymous type in a single statement. If you need more statements, you may end up with a pretty useless collection of different anonymous types.
Anonymous types are useful when you create them in a single statement, and use them right away. If the creation of the collection or the further processing is a bit more complex, the anonymous type loses some of it's usefulness. For example, you can't efficiently pass an anonymous type along to a method for processing, as the method doesn't know the type of the object and thus have to use reflection to get anything out of it.
If you are going to repeatedly look for items in this collection of anonymous types, you may want to create a named type so that you can put them in a Dictionary for much faster lookup.