ObjectQuery<T>.Include(String) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
쿼리 결과에 포함할 관련 개체를 지정합니다.
public:
System::Data::Objects::ObjectQuery<T> ^ Include(System::String ^ path);
public System.Data.Objects.ObjectQuery<T> Include (string path);
member this.Include : string -> System.Data.Objects.ObjectQuery<'T>
Public Function Include (path As String) As ObjectQuery(Of T)
매개 변수
- path
- String
쿼리 결과에 반환할 관련 개체의 목록입니다(점으로 구분됨).
반환
쿼리 경로가 정의된 새 ObjectQuery<T>입니다.
예외
path
이(가) null
인 경우
path
이(가) empty
인 경우
예제
using (AdventureWorksEntities context =
new AdventureWorksEntities())
{
// Define an object query with a path that returns
// orders and items for a specific contact.
Contact contact =
context.Contacts.Include("SalesOrderHeaders.SalesOrderDetails")
.FirstOrDefault();
// Execute the query and display information for each item
// in the orders that belong to the first contact.
foreach (SalesOrderHeader order in contact
.SalesOrderHeaders)
{
Console.WriteLine(String.Format("PO Number: {0}",
order.PurchaseOrderNumber));
Console.WriteLine(String.Format("Order Date: {0}",
order.OrderDate.ToString()));
Console.WriteLine("Order items:");
foreach (SalesOrderDetail item in order.SalesOrderDetails)
{
Console.WriteLine(String.Format("Product: {0} "
+ "Quantity: {1}", item.ProductID.ToString(),
item.OrderQty.ToString()));
}
}
}
설명
쿼리 경로는 Entity SQL 및 LINQ 쿼리와 함께 사용할 수 있습니다.
경로는 모두 포함됩니다. 예를 들어 include 호출이 를 나타내는 Include("Orders.OrderLines")
경우 는 포함될 뿐만 아니라 도 Orders
포함됩니다OrderLines
. 자세한 내용은 관련 개체 로드를 참조하세요.
메서드를 Include 호출할 때 쿼리 경로는 의 반환된 instance만 유효합니다ObjectQuery<T>. 및 개체 컨텍스트 자체의 ObjectQuery<T> 다른 인스턴스는 영향을 받지 않습니다.
메서드는 Include 쿼리 개체를 반환하므로 다음 예제와 같이 에서 이 메서드를 ObjectQuery<T> 여러 번 호출하여 쿼리에 대한 여러 경로를 지정할 수 있습니다.
// Create a SalesOrderHeader query with two query paths,
// one that returns order items and a second that returns the
// billing and shipping addresses for each order.
ObjectQuery<SalesOrderHeader> query =
context.SalesOrderHeaders.Include("SalesOrderDetails").Include("Address");
적용 대상
추가 정보
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기