コード例 #1
0
 public DbReferenceEntry <TEntity, TProperty> Reference <TProperty>(
     Expression <Func <TEntity, TProperty> > navigationProperty)
     where TProperty : class
 {
     Check.NotNull <Expression <Func <TEntity, TProperty> > >(navigationProperty, nameof(navigationProperty));
     return(DbReferenceEntry <TEntity, TProperty> .Create(this._internalEntityEntry.Reference(DbHelpers.ParsePropertySelector <TEntity, TProperty>(navigationProperty, nameof(Reference), nameof(navigationProperty)), typeof(TProperty))));
 }
コード例 #2
0
 /// <summary>
 /// Gets an object that represents the reference (i.e. non-collection) navigation property from this
 /// entity to another entity.
 /// </summary>
 /// <typeparam name="TProperty"> The type of the property. </typeparam>
 /// <param name="navigationProperty"> The name of the navigation property. </param>
 /// <returns> An object representing the navigation property. </returns>
 public DbReferenceEntry <TEntity, TProperty> Reference <TProperty>(
     string navigationProperty)
     where TProperty : class
 {
     Check.NotEmpty(navigationProperty, nameof(navigationProperty));
     return(DbReferenceEntry <TEntity, TProperty> .Create(this._internalEntityEntry.Reference(navigationProperty, typeof(TProperty))));
 }
コード例 #3
0
            public void Generic_DbReferenceEntry_typed_as_DbMemberEntry_can_be_implicitly_converted_to_non_generic_DbReferenceEntry()
            {
                DbMemberEntry <FakeWithProps, FakeEntity> propEntry =
                    new DbReferenceEntry <FakeWithProps, FakeEntity>(
                        new InternalReferenceEntry(
                            new Mock <InternalEntityEntryForMock <FakeEntity> >().Object, FakeWithProps.ReferenceMetadata));

                NonGenericTestMethod((DbReferenceEntry)propEntry, "Reference");
            }
コード例 #4
0
        /// <summary>
        /// Returns the equivalent generic <see cref="T:System.Data.Entity.Infrastructure.DbReferenceEntry`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 DbReferenceEntry <TEntity, TProperty> Cast <TEntity, TProperty>() where TEntity : class
        {
            MemberEntryMetadata entryMetadata = this._internalReferenceEntry.EntryMetadata;

            if (!typeof(TEntity).IsAssignableFrom(entryMetadata.DeclaringType) || !typeof(TProperty).IsAssignableFrom(entryMetadata.ElementType))
            {
                throw Error.DbMember_BadTypeForCast((object)typeof(DbReferenceEntry).Name, (object)typeof(TEntity).Name, (object)typeof(TProperty).Name, (object)entryMetadata.DeclaringType.Name, (object)entryMetadata.MemberType.Name);
            }
            return(DbReferenceEntry <TEntity, TProperty> .Create(this._internalReferenceEntry));
        }
コード例 #5
0
        public DbReferenceEntry <TEntity, TProperty> Reference <TProperty>(
            Expression <Func <TEntity, TProperty> > navigationProperty)
            where TProperty : class
        {
            Check.NotNull(navigationProperty, "navigationProperty");

            return
                (DbReferenceEntry <TEntity, TProperty> .Create(
                     _internalEntityEntry.Reference(
                         DbHelpers.ParsePropertySelector(navigationProperty, "Reference", "navigationProperty"),
                         typeof(TProperty))));
        }
コード例 #6
0
        /// <summary>
        /// Returns the equivalent generic <see cref="DbReferenceEntry{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 DbReferenceEntry<TEntity, TProperty> Cast<TEntity, TProperty>() where TEntity : class
        {
            var metadata = _internalReferenceEntry.EntryMetadata;
            if (!typeof(TEntity).IsAssignableFrom(metadata.DeclaringType)
                || !typeof(TProperty).IsAssignableFrom(metadata.ElementType))
            {
                throw Error.DbMember_BadTypeForCast(
                    typeof(DbReferenceEntry).Name,
                    typeof(TEntity).Name,
                    typeof(TProperty).Name,
                    metadata.DeclaringType.Name,
                    metadata.MemberType.Name);
            }

            return DbReferenceEntry<TEntity, TProperty>.Create(_internalReferenceEntry);
        }
コード例 #7
0
 private static DbReferenceEntry ImplicitConvert(DbReferenceEntry nonGeneric)
 {
     return(nonGeneric);
 }
コード例 #8
0
 private void NonGenericTestMethod(DbReferenceEntry nonGenericEntry, string name)
 {
     Assert.Same(name, nonGenericEntry.Name);
 }
コード例 #9
0
        /// <summary>
        ///     Gets an object that represents the reference (i.e. non-collection) navigation property from this
        ///     entity to another entity.
        /// </summary>
        /// <param name="navigationProperty"> The name of the navigation property. </param>
        /// <returns> An object representing the navigation property. </returns>
        public DbReferenceEntry Reference(string navigationProperty)
        {
            Check.NotEmpty(navigationProperty, "navigationProperty");

            return(DbReferenceEntry.Create(_internalEntityEntry.Reference(navigationProperty)));
        }
コード例 #10
0
 /// <summary>
 /// Gets an object that represents the reference (i.e. non-collection) navigation property from this
 /// entity to another entity.
 /// </summary>
 /// <param name="navigationProperty"> The name of the navigation property. </param>
 /// <returns> An object representing the navigation property. </returns>
 public DbReferenceEntry Reference(string navigationProperty)
 {
     Check.NotEmpty(navigationProperty, nameof(navigationProperty));
     return(DbReferenceEntry.Create(this._internalEntityEntry.Reference(navigationProperty, (Type)null)));
 }