This project has moved and is read-only. For the latest updates, please go here.

Exporting IEnumerable<T> vs. Importing IEnumerable<T>

Dec 22, 2008 at 11:43 AM

Suppose we have the following exports and imports:

T source1;

T source2;

IEnumerable<T> source3;

IEnumerable<T> target;

What will the be the contents of the target import?

Dec 22, 2008 at 6:24 PM
The contents of target will be (source1, source2), it will not include anything from source3. Including individual items from source3, what we refer to as flattening the export, is not supported because it would destroy lazy loading. What I mean by that is in order for us to use source3 we would have to instantiate an instance of the type that holds source3 and pull on the collection in order to figure out how many items exist in that collection. This early instantiation is what kills our lazy loading. We do not have to do any early instantiation for source1 and source2 because we can figure out everything we need from the metadata.

We have explored adding the "Export flattening" feature a number of times and we always end up not being able to support it.
Dec 22, 2008 at 6:26 PM
As a followup if you did want to export collections then on the import side you would have to import a collection of collections and flatten yourself, for example:

IEnumerable<T> source4

IEnumerable<T> source5

IEnumerable<IEnumerable<T>> target;