EntityReference<TEntity> 클래스

정의

다중성이 0 또는 1인 연결의 관련 End를 나타냅니다.

generic <typename TEntity>
 where TEntity : class, IEntityWithRelationshipspublic ref class EntityReference sealed : System::Data::Objects::DataClasses::EntityReference
generic <typename TEntity>
 where TEntity : classpublic ref class EntityReference sealed : System::Data::Objects::DataClasses::EntityReference
[System.Runtime.Serialization.DataContract]
[System.Serializable]
public sealed class EntityReference<TEntity> : System.Data.Objects.DataClasses.EntityReference where TEntity : class, IEntityWithRelationships
[System.Runtime.Serialization.DataContract]
[System.Serializable]
public sealed class EntityReference<TEntity> : System.Data.Objects.DataClasses.EntityReference where TEntity : class
[<System.Runtime.Serialization.DataContract>]
[<System.Serializable>]
type EntityReference<'Entity (requires 'Entity : null and 'Entity :> IEntityWithRelationships)> = class
    inherit EntityReference
[<System.Runtime.Serialization.DataContract>]
[<System.Serializable>]
type EntityReference<'Entity (requires 'Entity : null)> = class
    inherit EntityReference
Public NotInheritable Class EntityReference(Of TEntity)
Inherits EntityReference

형식 매개 변수

TEntity

참조의 엔터티 형식입니다.

상속
EntityReference<TEntity>
특성

예제

이 예제에서는 사용 하는 EntityReference<TEntity> 방법을 보여 줍니다는 개체와 순서에 대 한 SalesOrderHeader 배송 주소를 나타내는 관련 Address 개체 간의 관계를 변경 하는 개체입니다.


// Define the order and new address IDs.
int orderId = 43669;
int addressId = 26;

using (AdventureWorksEntities context
    = new AdventureWorksEntities())
{
    // Get the billing address to change to.
    Address address =
        context.Addresses.Single(c => c.AddressID == addressId);

    // Get the order being changed.
    SalesOrderHeader order =
        context.SalesOrderHeaders.Single(o => o.SalesOrderID == orderId);

    // You do not have to call the Load method to load the addresses for the order,
    // because  lazy loading is set to true
    // by the constructor of the AdventureWorksEntities object.
    // With  lazy loading set to true the related objects are loaded when
    // you access the navigation property. In this case Address.

    // Write the current billing street address.
    Console.WriteLine("Current street: "
        + order.Address.AddressLine1);

    // Change the billing address.
    if (!order.Address.Equals(address))
    {
        // Use Address navigation property to change the association.
        order.Address = address;

        // Write the changed billing street address.
        Console.WriteLine("Changed street: "
            + order.Address.AddressLine1);
    }

    // If the address change succeeds, save the changes.
    context.SaveChanges();

    // Write the current billing street address.
    Console.WriteLine("Current street: "
        + order.Address.AddressLine1);
}

설명

관련 End의 다중성이 0 또는 1이면 탐색 속성에 의해 EntityReference<TEntity> 개체가 반환됩니다. 자세한 내용은 NavigationProperty 요소 (CSDL)합니다.

개체는 EntityReference<TEntity> 관계의 다른 쪽 끝에 해당하는 EntityCollection<TEntity> (일 대 다 관계) 또는 EntityReference<TEntity> (일대일 관계)를 가질 수 있습니다. 와 EntityReference<TEntity>EntityCollection<TEntity> 모델이 같은 관계의 끝을 반대하면 관계의 무결성이 개체 수준에서 유지됩니다.

이 클래스는 상속될 수 없습니다.

생성자

EntityReference<TEntity>()

EntityReference<TEntity>의 새 인스턴스를 만듭니다.

속성

EntityKey

관련 개체의 키를 반환합니다.

(다음에서 상속됨 EntityReference)
IsLoaded

관련 개체가 모두 로드되었는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 RelatedEnd)
RelationshipName

이 관련 End가 참여하는 관계의 이름을 가져옵니다.

(다음에서 상속됨 RelatedEnd)
RelationshipSet

관련 End의 메타데이터에 대한 참조를 가져옵니다.

(다음에서 상속됨 RelatedEnd)
SourceRoleName

관계의 소스 End에 있는 역할 이름을 가져옵니다.

(다음에서 상속됨 RelatedEnd)
TargetRoleName

관계의 대상 End에 있는 역할 이름을 가져옵니다.

(다음에서 상속됨 RelatedEnd)
Value

EntityReference<TEntity>에서 반환되는 관련 개체를 가져오거나 설정합니다.

메서드

Attach(TEntity)

개체 컨텍스트의 두 개체 간에 다대일 또는 일대일 관계를 만듭니다.

Attach<TEntity>(IEnumerable<TEntity>, Boolean)

연결된 두 개체 간의 관계를 정의합니다.

(다음에서 상속됨 RelatedEnd)
CreateSourceQuery()

관련 개체를 반환하는 해당 개체 쿼리를 만듭니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetEnumerator()

관련 개체의 컬렉션을 반복하는 IEnumerator를 반환합니다.

(다음에서 상속됨 RelatedEnd)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
Load()

파생 클래스에서 재정의되면 기본 병합 옵션을 사용하여 관련 개체를 관련 End에 로드합니다.

(다음에서 상속됨 RelatedEnd)
Load(MergeOption)

지정된 병합 옵션을 사용하여 이 EntityReference<TEntity>의 관련 개체를 로드합니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
Merge<TEntity>(IEnumerable<TEntity>, MergeOption, Boolean)

관련 엔터티를 로컬 EntityCollection<TEntity>에 병합합니다.

(다음에서 상속됨 RelatedEnd)
OnDeserialized(StreamingContext)

RelationshipManager 인스턴스와 함께 엔터티 개체를 역직렬화하기 위해 내부적으로 사용됩니다.

(다음에서 상속됨 RelatedEnd)
OnRefDeserialized(StreamingContext)

이 메서드는 관련 엔터티 개체를 serialize하기 위해 내부적으로 사용됩니다.

OnSerializing(StreamingContext)

이 메서드는 관련 엔터티 개체를 serialize하기 위해 내부적으로 사용됩니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)
ValidateEntityForAttach<TEntity>(TEntity, Int32, Boolean)

개체를 로컬 컬렉션 또는 참조에 연결할 수 있는지 여부를 결정합니다.

(다음에서 상속됨 RelatedEnd)
ValidateLoad<TEntity>(MergeOption, String)

관련 개체를 로컬 컬렉션 또는 참조에 성공적으로 로드할 수 있는지 확인합니다.

(다음에서 상속됨 RelatedEnd)
ValidateOwnerForAttach()

관련 end가 속하는 개체에서 연결 조작을 지원하는지 확인합니다.

(다음에서 상속됨 RelatedEnd)

이벤트

AssociationChanged

관련 End가 변경될 때 발생합니다.

(다음에서 상속됨 RelatedEnd)

명시적 인터페이스 구현

IRelatedEnd.Add(IEntityWithRelationships)

개체를 관련 End에 추가합니다.

(다음에서 상속됨 RelatedEnd)
IRelatedEnd.Add(Object)

개체를 관련 End에 추가합니다.

(다음에서 상속됨 RelatedEnd)
IRelatedEnd.Attach(IEntityWithRelationships)

개체를 관련 End에 연결합니다.

(다음에서 상속됨 RelatedEnd)
IRelatedEnd.Attach(Object)

개체를 관련 End에 연결합니다.

(다음에서 상속됨 RelatedEnd)
IRelatedEnd.CreateSourceQuery()

관련 End에 속하는 개체를 나타내는 IEnumerable을 반환합니다.

(다음에서 상속됨 RelatedEnd)
IRelatedEnd.Remove(IEntityWithRelationships)

관련 End의 컬렉션에서 개체를 제거합니다.

(다음에서 상속됨 RelatedEnd)
IRelatedEnd.Remove(Object)

개체가 관련 End의 일부인 경우 관련 End에서 개체를 제거합니다.

(다음에서 상속됨 RelatedEnd)

적용 대상