Is an object still connected to a list after FirstOrDefault?

list is not changed, and still includes the object returned by FirstOrDefault.

This is a general rule with all the LINQ operators: they never modify the source collection.

Also note that thisEvent is not a "copy" (unless Event is a value type (struct) rather than a class) -- it is a reference to the same object that is referenced in list.


FirstOrDefault selects an item in a collection, but does not "detatch" or "clone" it. I.e. it is the same instance. So if you modify a property you modify the original instance.

If you want to "detatch" the object you will have to copy it in some way or the other.


Beware, this is true if your collection is in memory. If your collection is the result of a database query, the collection is not materialized until you call ToList on it. If you do FirstOrDefault before that, it will make a query to the database to return only this result and then materializing your collection will make a seperate call to the DB and you will not share the same instance. It just happened to me so I hope this can help someone else.