src/Shared/EntityFramework/Internal/EntityEntries/InternalCollectionEntry.cs
// <summary>
// Creates a <see cref="DbCollectionEntry{TEntity,TElement}" /> object for the given entity type
// and collection element type.
// </summary>
// <typeparam name="TEntity"> The type of the entity. </typeparam>
// <typeparam name="TProperty"> The type of the property. </typeparam>
// <param name="elementType"> Type of the element. </param>
// <returns> The set. </returns>
Creates a  object for the given entity type
and collection element type.
Creates a object for the given entity type and collection element type .
private DbMemberEntry<TEntity, TProperty> CreateDbCollectionEntry<TEntity, TProperty>(Type elementType)
            where TEntity : class
        {
            var targetType = typeof(DbMemberEntry<TEntity, TProperty>);
            Func<InternalCollectionEntry, object> factory;
            if (!_entryFactories.TryGetValue(targetType, out factory))
            {
                var genericType = typeof(DbCollectionEntry<,>).MakeGenericType(typeof(TEntity), elementType);
                if (!targetType.IsAssignableFrom(genericType))
                {
                    throw Error.DbEntityEntry_WrongGenericForCollectionNavProp(
                        typeof(TProperty),
                        Name,
                        EntryMetadata.DeclaringType,
                        typeof(ICollection<>).MakeGenericType(elementType));
                }
                var factoryMethod = genericType.GetDeclaredMethod("Create", typeof(InternalCollectionEntry));
                factory =
                    (Func<InternalCollectionEntry, object>)
                    Delegate.CreateDelegate(typeof(Func<InternalCollectionEntry, object>), factoryMethod);
                _entryFactories.TryAdd(targetType, factory);
            }
            return (DbMemberEntry<TEntity, TProperty>)factory(this);
        }
private DbMemberEntry < TEntity , TProperty > CreateDbCollectionEntry < TEntity , TProperty > ( Type elementType ) where TEntity : class { var targetType = typeof ( DbMemberEntry < TEntity , TProperty > ) ; Func < InternalCollectionEntry , object > factory ; if ( ! _entryFactories . TryGetValue ( targetType , out factory ) ) { var genericType = typeof ( DbCollectionEntry < , > ) . MakeGenericType ( typeof ( TEntity ) , elementType ) ; if ( ! targetType . IsAssignableFrom ( genericType ) ) { throw Error . DbEntityEntry_WrongGenericForCollectionNavProp ( typeof ( TProperty ) , Name , EntryMetadata . DeclaringType , typeof ( ICollection < > ) . MakeGenericType ( elementType ) ) ; } var factoryMethod = genericType . GetDeclaredMethod ( " " , typeof ( InternalCollectionEntry ) ) ; factory = ( Func < InternalCollectionEntry , object > ) Delegate . CreateDelegate ( typeof ( Func < InternalCollectionEntry , object > ) , factoryMethod ) ; _entryFactories . TryAdd ( targetType , factory ) ; } return ( DbMemberEntry < TEntity , TProperty > ) factory ( this ) ; }
Creates a  object for the given entity type
and collection element type.
Creates a object for the given entity type and collection element type .
None
elementType
Type
Type of the element.
Type of the element .
typeparam
The type of the entity.
The type of the entity .
typeparam
The type of the property.
The type of the property .