/// <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))));
        }
Пример #2
0
            public void Generic_DbPropertyEntry_typed_as_DbMemberEntry_can_be_explicitly_converted_to_non_generic_DbPropertyEntry()
            {
                DbMemberEntry <FakeWithProps, FakeEntity> propEntry =
                    new DbPropertyEntry <FakeWithProps, FakeEntity>(
                        new InternalEntityPropertyEntry(
                            new Mock <InternalEntityEntryForMock <FakeEntity> >().Object,
                            FakeEntity.FakeNamedFooPropertyMetadata));

                NonGenericTestMethod((DbPropertyEntry)propEntry, "Foo");
            }
Пример #3
0
            public void Generic_DbPropertyEntry_can_be_implicitly_converted_to_non_generic_version()
            {
                var propEntry =
                    new DbPropertyEntry <FakeWithProps, FakeEntity>(
                        new InternalEntityPropertyEntry(
                            new Mock <InternalEntityEntryForMock <FakeEntity> >().Object,
                            FakeEntity.FakeNamedFooPropertyMetadata));

                NonGenericTestMethod(propEntry, "Foo");
            }
Пример #4
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));
        }
Пример #5
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)));
        }
Пример #7
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)));
 }
Пример #8
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)));
 }
Пример #9
0
 private static DbPropertyEntry ImplicitConvert(DbPropertyEntry nonGeneric)
 {
     return(nonGeneric);
 }
Пример #10
0
 private void NonGenericTestMethod(DbPropertyEntry nonGenericEntry, string name)
 {
     Assert.Same(name, nonGenericEntry.Name);
 }
Пример #11
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)));
 }