/// <summary>
        /// Gets an object that represents a nested property of this property.
        /// This method can be used for both scalar or complex properties.
        /// </summary>
        /// <typeparam name="TNestedProperty"> 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 DbPropertyEntry <TEntity, TNestedProperty> Property <TNestedProperty>(string propertyName)
        {
            Check.NotEmpty(propertyName, "propertyName");

            return
                (DbPropertyEntry <TEntity, TNestedProperty> .Create(
                     InternalPropertyEntry.Property(propertyName, typeof(TNestedProperty))));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the equivalent generic <see cref="T:System.Data.Entity.Infrastructure.DbPropertyEntry`2" /> object.
        /// </summary>
        /// <typeparam name="TEntity"> The type of entity on which the member is declared. </typeparam>
        /// <typeparam name="TProperty"> The type of the property. </typeparam>
        /// <returns> The equivalent generic object. </returns>
        public DbPropertyEntry <TEntity, TProperty> Cast <TEntity, TProperty>() where TEntity : class
        {
            PropertyEntryMetadata entryMetadata = this._internalPropertyEntry.EntryMetadata;

            if (!typeof(TEntity).IsAssignableFrom(entryMetadata.DeclaringType) || !typeof(TProperty).IsAssignableFrom(entryMetadata.ElementType))
            {
                throw Error.DbMember_BadTypeForCast((object)typeof(DbPropertyEntry).Name, (object)typeof(TEntity).Name, (object)typeof(TProperty).Name, (object)entryMetadata.DeclaringType.Name, (object)entryMetadata.MemberType.Name);
            }
            return(DbPropertyEntry <TEntity, TProperty> .Create(this._internalPropertyEntry));
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Returns the equivalent generic <see cref="DbPropertyEntry{TEntity,TProperty}" /> object.
        /// </summary>
        /// <typeparam name="TEntity"> The type of entity on which the member is declared. </typeparam>
        /// <typeparam name="TProperty"> The type of the property. </typeparam>
        /// <returns> The equivalent generic object. </returns>
        public new DbPropertyEntry <TEntity, TProperty> Cast <TEntity, TProperty>() where TEntity : class
        {
            var metadata = _internalPropertyEntry.EntryMetadata;

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

            return(DbPropertyEntry <TEntity, TProperty> .Create(_internalPropertyEntry));
        }
        /// <summary>
        /// Gets an object that represents a nested property of this property.
        /// This method can be used for both scalar or complex properties.
        /// </summary>
        /// <param name="propertyName"> The name of the nested property. </param>
        /// <returns> An object representing the nested property. </returns>
        public DbPropertyEntry Property(string propertyName)
        {
            Check.NotEmpty(propertyName, "propertyName");

            return(DbPropertyEntry.Create(InternalPropertyEntry.Property(propertyName)));
        }
Exemplo n.º 5
0
 /// <summary>
 /// Gets an object that represents a nested property of this property.
 /// This method can be used for both scalar or complex properties.
 /// </summary>
 /// <param name="propertyName"> The name of the nested property. </param>
 /// <returns> An object representing the nested property. </returns>
 public DbPropertyEntry Property(string propertyName)
 {
     Check.NotEmpty(propertyName, nameof(propertyName));
     return(DbPropertyEntry.Create(((InternalPropertyEntry)this.InternalMemberEntry).Property(propertyName, (Type)null, false)));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Gets an object that represents a scalar or complex property of this entity.
 /// </summary>
 /// <param name="propertyName"> The name of the property. </param>
 /// <returns> An object representing the property. </returns>
 public DbPropertyEntry Property(string propertyName)
 {
     Check.NotEmpty(propertyName, nameof(propertyName));
     return(DbPropertyEntry.Create(this._internalEntityEntry.Property(propertyName, (Type)null, false)));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Gets an object that represents a scalar or complex property of this entity.
 /// </summary>
 /// <typeparam name="TProperty"> The type of the property. </typeparam>
 /// <param name="propertyName"> The name of the property. </param>
 /// <returns> An object representing the property. </returns>
 public DbPropertyEntry <TEntity, TProperty> Property <TProperty>(
     string propertyName)
 {
     Check.NotEmpty(propertyName, nameof(propertyName));
     return(DbPropertyEntry <TEntity, TProperty> .Create(this._internalEntityEntry.Property(propertyName, typeof(TProperty), false)));
 }