src/Shared/EntityFramework/Core/Objects/DataClasses/EntityCollection.cs
// This method is required to maintain compatibility with the v1 binary serialization format. 
// In particular, it takes the dictionary of wrapped entities and creates a hash set of
// raw entities that will be serialized.
// Note that this is only expected to work for non-POCO entities, since serialization of POCO
// entities will not result in serialization of the RelationshipManager or its related objects.
/// <summary>Used internally to serialize entity objects.</summary>
/// <param name="context">The streaming context.</param>
Used internally to serialize entity objects.
Used internally to serialize entity objects .
[SuppressMessage("Microsoft.Usage", "CA2238:ImplementSerializationMethodsCorrectly")]
        [OnSerializing]
        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public void OnSerializing(StreamingContext context)
        {
            if (!(WrappedOwner.Entity is IEntityWithRelationships))
            {
                throw new InvalidOperationException(Strings.RelatedEnd_CannotSerialize("EntityCollection"));
            }
            _relatedEntities = _wrappedRelatedEntities == null ? null : new HashSet<TEntity>(_wrappedRelatedEntities.Keys, ObjectReferenceEqualityComparer.Default);
        }
[ SuppressMessage ( " " , " " ) ] [ OnSerializing ] [ Browsable ( false ) ] [ EditorBrowsable ( EditorBrowsableState . Never ) ] public void OnSerializing ( StreamingContext context ) { if ( ! ( WrappedOwner . Entity is IEntityWithRelationships ) ) { throw new InvalidOperationException ( Strings . RelatedEnd_CannotSerialize ( " " ) ) ; } _relatedEntities = _wrappedRelatedEntities == null ? null : new HashSet < TEntity > ( _wrappedRelatedEntities . Keys , ObjectReferenceEqualityComparer . Default ) ; }
Used internally to serialize entity objects.
Used internally to serialize entity objects .
context
StreamingContext
The streaming context.
The streaming context .