EntityReference<TEntity> 클래스

정의

0 또는 1의 곱셈이 있는 연결의 관련 끝을 나타냅니다.

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> 배송 주소를 나타내는 관련 Address 개체와 개체 간의 SalesOrderHeader 관계를 변경하는 방법을 보여 줍니다.


// 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);
}

설명

EntityReference<TEntity> 관련 끝에 0 또는 1의 곱셈이 있는 경우 탐색 속성에 의해 개체가 반환됩니다. 자세한 내용은 NavigationProperty 요소(CSDL)를 참조하세요.

개체는 EntityReference<TEntity> 관계의 다른 쪽 끝에 해당 EntityCollection<TEntity> (일대다 관계) 또는 EntityReference<TEntity> (일 대 일 관계)을 가질 수 있습니다. EntityReference<TEntity> EntityCollection<TEntity> 동일한 관계의 끝과 반대되는 모델인 경우 관계의 무결성은 개체 수준에서 유지됩니다.

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

생성자

Name Description
EntityReference<TEntity>()

EntityReference<TEntity>새 인스턴스를 생성합니다.

속성

Name Description
EntityKey

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

(다음에서 상속됨 EntityReference)
IsLoaded

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

(다음에서 상속됨 RelatedEnd)
RelationshipName

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

(다음에서 상속됨 RelatedEnd)
RelationshipSet

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

(다음에서 상속됨 RelatedEnd)
SourceRoleName

관계의 원본 끝에 있는 역할 이름을 가져옵니다.

(다음에서 상속됨 RelatedEnd)
TargetRoleName

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

(다음에서 상속됨 RelatedEnd)
Value

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

메서드

Name Description
Attach(TEntity)

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

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

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

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

관련 개체를 반환하는 동등한 개체 쿼리를 만듭니다.

Equals(Object)

지정한 개체와 현재 개체가 같은지 여부를 확인합니다.

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

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

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

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

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

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

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

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

(다음에서 상속됨 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()

관련 엔드가 속한 개체가 연결 작업을 지원하는지 확인합니다.

(다음에서 상속됨 RelatedEnd)

이벤트

Name Description
AssociationChanged

관련 끝에 변경이 있을 때 발생합니다.

(다음에서 상속됨 RelatedEnd)

명시적 인터페이스 구현

Name Description
IRelatedEnd.Add(IEntityWithRelationships)

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

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

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

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

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

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

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

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

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

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

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

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

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

(다음에서 상속됨 RelatedEnd)

적용 대상