/// <summary>
        ///     Gets an object that represents a nested complex property of this property.
        /// </summary>
        /// <param name="propertyName"> The name of the nested property. </param>
        /// <returns> An object representing the nested property. </returns>
        public DbComplexPropertyEntry ComplexProperty(string propertyName)
        {
            Check.NotEmpty(propertyName, "propertyName");

            return
                (DbComplexPropertyEntry.Create(InternalPropertyEntry.Property(propertyName, null, requireComplex: true)));
        }
        /// <summary>
        ///     Gets an object that represents a complex property of this entity.
        /// </summary>
        /// <typeparam name="TComplexProperty"> The type of the complex property. </typeparam>
        /// <param name="propertyName"> The name of the complex property. </param>
        /// <returns> An object representing the complex property. </returns>
        public DbComplexPropertyEntry <TEntity, TComplexProperty> ComplexProperty <TComplexProperty>(string propertyName)
        {
            Check.NotEmpty(propertyName, "propertyName");

            return
                (DbComplexPropertyEntry <TEntity, TComplexProperty> .Create(
                     _internalEntityEntry.Property(propertyName, typeof(TComplexProperty), requireComplex: true)));
        }
示例#3
0
        /// <summary>
        /// Returns the equivalent generic <see cref="T:System.Data.Entity.Infrastructure.DbComplexPropertyEntry`2" /> object.
        /// </summary>
        /// <typeparam name="TEntity"> The type of entity on which the member is declared. </typeparam>
        /// <typeparam name="TComplexProperty"> The type of the complex property. </typeparam>
        /// <returns> The equivalent generic object. </returns>
        public DbComplexPropertyEntry <TEntity, TComplexProperty> Cast <TEntity, TComplexProperty>() where TEntity : class
        {
            MemberEntryMetadata entryMetadata = this.InternalMemberEntry.EntryMetadata;

            if (!typeof(TEntity).IsAssignableFrom(entryMetadata.DeclaringType) || !typeof(TComplexProperty).IsAssignableFrom(entryMetadata.ElementType))
            {
                throw Error.DbMember_BadTypeForCast((object)typeof(DbComplexPropertyEntry).Name, (object)typeof(TEntity).Name, (object)typeof(TComplexProperty).Name, (object)entryMetadata.DeclaringType.Name, (object)entryMetadata.MemberType.Name);
            }
            return(DbComplexPropertyEntry <TEntity, TComplexProperty> .Create((InternalPropertyEntry)this.InternalMemberEntry));
        }
            public void Parent_PropertyEntity_can_be_obtained_from_nested_non_generic_DbComplexPropertyEntry_back_reference()
            {
                var mockInternalEntry = FakeWithProps.CreateMockInternalEntityEntry();
                var propEntry         =
                    new DbComplexPropertyEntry <FakeWithProps, FakeWithProps>(
                        new InternalEntityPropertyEntry(mockInternalEntry.Object, FakeWithProps.ComplexPropertyMetadata));

                var backEntry = propEntry.Property("ValueTypeProp").ParentProperty;

                Assert.Same(propEntry.Name, backEntry.Name);
            }
        /// <summary>
        ///     Returns the equivalent generic <see cref="DbComplexPropertyEntry{TEntity,TComplexProperty}" /> object.
        /// </summary>
        /// <typeparam name="TEntity"> The type of entity on which the member is declared. </typeparam>
        /// <typeparam name="TComplexProperty"> The type of the complex property. </typeparam>
        /// <returns> The equivalent generic object. </returns>
        public new DbComplexPropertyEntry <TEntity, TComplexProperty> Cast <TEntity, TComplexProperty>()
            where TEntity : class
        {
            var metadata = InternalMemberEntry.EntryMetadata;

            if (!typeof(TEntity).IsAssignableFrom(metadata.DeclaringType) ||
                !typeof(TComplexProperty).IsAssignableFrom(metadata.ElementType))
            {
                throw Error.DbMember_BadTypeForCast(
                          typeof(DbComplexPropertyEntry).Name,
                          typeof(TEntity).Name,
                          typeof(TComplexProperty).Name,
                          metadata.DeclaringType.Name,
                          metadata.MemberType.Name);
            }

            return(DbComplexPropertyEntry <TEntity, TComplexProperty> .Create((InternalPropertyEntry)InternalMemberEntry));
        }
示例#6
0
 public DbComplexPropertyEntry ComplexProperty(string propertyName)
 {
     Check.NotEmpty(propertyName, nameof(propertyName));
     return(DbComplexPropertyEntry.Create(((InternalPropertyEntry)this.InternalMemberEntry).Property(propertyName, (Type)null, true)));
 }
示例#7
0
 /// <summary>
 /// Gets an object that represents a complex property of this entity.
 /// </summary>
 /// <param name="propertyName"> The name of the complex property. </param>
 /// <returns> An object representing the complex property. </returns>
 public DbComplexPropertyEntry ComplexProperty(string propertyName)
 {
     Check.NotEmpty(propertyName, nameof(propertyName));
     return(DbComplexPropertyEntry.Create(this._internalEntityEntry.Property(propertyName, (Type)null, true)));
 }
示例#8
0
 /// <summary>
 /// Gets an object that represents a nested complex property of this property.
 /// </summary>
 /// <typeparam name="TNestedComplexProperty"> The type of the nested property. </typeparam>
 /// <param name="propertyName"> The name of the nested property. </param>
 /// <returns> An object representing the nested property. </returns>
 public DbComplexPropertyEntry <TEntity, TNestedComplexProperty> ComplexProperty <TNestedComplexProperty>(
     string propertyName)
 {
     Check.NotEmpty(propertyName, nameof(propertyName));
     return(DbComplexPropertyEntry <TEntity, TNestedComplexProperty> .Create(this.InternalPropertyEntry.Property(propertyName, typeof(TNestedComplexProperty), true)));
 }