/// <summary> /// Creates a <see cref="DbReferenceEntry{TEntity,TProperty}" /> from information in the given /// <see /// cref="InternalReferenceEntry" /> /// . /// Use this method in preference to the constructor since it may potentially create a subclass depending on /// the type of member represented by the InternalCollectionEntry instance. /// </summary> /// <param name="internalReferenceEntry"> The internal reference entry. </param> /// <returns> The new entry. </returns> internal static DbReferenceEntry <TEntity, TProperty> Create(InternalReferenceEntry internalReferenceEntry) { DebugCheck.NotNull(internalReferenceEntry); return ((DbReferenceEntry <TEntity, TProperty>)internalReferenceEntry.CreateDbMemberEntry <TEntity, TProperty>()); }
private void InternalReferenceEntry_sets_current_value_onto_entity_if_property_exists_implementation(bool isDetached) { var entity = new FakeWithProps { Reference = new FakeEntity() }; var internalEntry = new InternalReferenceEntry( MockHelper.CreateMockInternalEntityEntry(entity, isDetached).Object, FakeWithProps.ReferenceMetadata); var relatedEntity = new FakeEntity(); internalEntry.CurrentValue = relatedEntity; Assert.Same(relatedEntity, entity.Reference); }
public void Generic_DbReferenceEntry_Name_returns_name_of_property_from_internal_entry() { var internalEntry = new InternalReferenceEntry( new Mock<InternalEntityEntryForMock<FakeEntity>>().Object, FakeWithProps.ReferenceMetadata); Assert.Equal("Reference", internalEntry.Name); }
/// <summary> /// Initializes a new instance of the <see cref="DbReferenceEntry{TEntity, TProperty}" /> class. /// </summary> /// <param name="internalReferenceEntry"> The internal entry. </param> internal DbReferenceEntry(InternalReferenceEntry internalReferenceEntry) { DebugCheck.NotNull(internalReferenceEntry); _internalReferenceEntry = internalReferenceEntry; }
InternalReferenceEntry_gets_current_value_from_RelatedEnd_if_navigation_property_has_been_removed_from_entity_implementation (FakeEntity relatedEntity) { var mockRelatedEnd = Core.Objects.DataClasses.MockHelper.CreateMockEntityReference(relatedEntity); var internalEntry = new InternalReferenceEntry( MockHelper.CreateMockInternalEntityEntry(new FakeEntity(), mockRelatedEnd.Object).Object, FakeWithProps.ReferenceMetadata); var propValue = internalEntry.CurrentValue; Assert.Same(relatedEntity, propValue); }
public void InternalReferenceEntry_Name_works_even_when_used_with_Detached_entity() { var mockInternalEntry = MockHelper.CreateMockInternalEntityEntry( new FakeEntity(), isDetached: true); var internalEntry = new InternalReferenceEntry(mockInternalEntry.Object, FakeWithProps.ReferenceMetadata); Assert.Equal("Reference", internalEntry.Name); }
public void InternalReferenceEntry_Query_throws_if_used_with_Detached_entity() { var mockInternalEntry = MockHelper.CreateMockInternalEntityEntry( new FakeEntity(), isDetached: true); var internalEntry = new InternalReferenceEntry(mockInternalEntry.Object, FakeWithProps.ReferenceMetadata); Assert.Equal( Strings.DbPropertyEntry_NotSupportedForDetached("Query", "Reference", "FakeEntity"), Assert.Throws<InvalidOperationException>(() => internalEntry.Query()).Message); }
public void InternalReferenceEntry_throws_setting_current_value_from_detached_entity_if_navigation_property_has_been_removed() { var mockInternalEntry = MockHelper.CreateMockInternalEntityEntry( new FakeEntity(), isDetached: true); var internalEntry = new InternalReferenceEntry(mockInternalEntry.Object, FakeWithProps.ReferenceMetadata); Assert.Equal( Strings.DbPropertyEntry_SettingEntityRefNotSupported("Reference", "FakeEntity", "Detached"), Assert.Throws<NotSupportedException>(() => { internalEntry.CurrentValue = null; }).Message); }
internal DbReferenceEntry(InternalReferenceEntry internalReferenceEntry) { this._internalReferenceEntry = internalReferenceEntry; }
internal static DbReferenceEntry <TEntity, TProperty> Create( InternalReferenceEntry internalReferenceEntry) { return((DbReferenceEntry <TEntity, TProperty>)internalReferenceEntry.CreateDbMemberEntry <TEntity, TProperty>()); }
/// <summary> /// Creates a <see cref="DbReferenceEntry" /> from information in the given <see cref="InternalReferenceEntry" />. /// Use this method in preference to the constructor since it may potentially create a subclass depending on /// the type of member represented by the InternalCollectionEntry instance. /// </summary> /// <param name="internalReferenceEntry"> The internal reference entry. </param> /// <returns> The new entry. </returns> internal static DbReferenceEntry Create(InternalReferenceEntry internalReferenceEntry) { DebugCheck.NotNull(internalReferenceEntry); return((DbReferenceEntry)internalReferenceEntry.CreateDbMemberEntry()); }
internal static DbReferenceEntry Create( InternalReferenceEntry internalReferenceEntry) { return((DbReferenceEntry)internalReferenceEntry.CreateDbMemberEntry()); }