It depends on whether you use (and how) to select the results.
If you do not create new objects in the projection, the result will refer to the same objects as the original collection.
If, however, you create new objects in the project, then obviously they will not be the same.
The collection returned here will contain references to the same objects in _myCollection :
from m in _myCollection where m.SomeFilterCriteria select m
Collections returned in these cases will not:
from m in _myCollection where m.SomeFilterCriteria select new { m.Prop1, m.Prop2 }
In this case, it is worth noting that Prop1 and Prop2 of the new anonymous object - if they are reference types - will contain a reference to the same object as the original object. Only the top-level links in the collection will be different.
Basically - nothing in .Net except serializers (as mentioned elsewhere here) will be a βdeepβ copy if you do not implement it.
or
from m in _myCollection where m.SomeFilterCriteria select m.Clone()
Again, it would be a mistake to assume that any βdeepβ copying is taking place here. Of course, the Clone implementation will be in the class and can be anything, including deep copying, but this is not indicated.
quentin-starin
source share