다음을 통해 공유


쿼리 경로 정의(EntityDataSource)

업데이트: 2007년 11월

EntityDataSource 컨트롤의 Include 속성을 사용하여 쿼리 경로를 쉼표로 구분된 목록으로 지정하면 특정 쿼리 개체와 함께 반환되는 개체를 정의할 수 있습니다. 문자열에서 쉼표로 구분된 각 값은 수정되지 않은 상태로 EntityDataSource 컨트롤의 데이터 소스인 ObjectQuery<T>Include 메서드에 대한 개별 호출로 전달됩니다.

Include 속성에 제공된 문자열은 ObjectQuery<T>Include 메서드에 전달된 문자열과 동일한 형식을 사용합니다. 쿼리 경로를 사용하여 관련 개체를 자동으로 로드하는 방법의 예제를 보려면 How to: Use Query Paths to Shape Results (Entity Framework)를 참조하십시오.

예제

다음 XML 태그에서는 반환된 Contact 개체와 관련된 SalesOrderHeader 개체를 반환하는 쿼리 경로를 정의합니다. 각 SalesOrderHeader와 함께 관련 SalesOrderDetail 및 Address 개체도 반환됩니다.

<asp:EntityDataSource ID="ContactDataSource"  
    AutoGenerateWhereClause="True" ConnectionString="name=AdventureWorksEntities" 
    DefaultContainerName="AdventureWorksEntities" EnableDelete="True" 
    EnableInsert="True" EnableUpdate="True" EntitySetName="Contact" 
    Include="SalesOrderHeader.SalesOrderDetail, SalesOrderHeader.Address">
    <WhereParameters>
        <asp:ControlParameter ControlID="customerId" Name="ContactID" 
            PropertyName="Text" />
    </WhereParameters>
</asp:EntityDataSource>

앞의 XML 예제는 contacts라는 다음 ObjectQuery<T>와 같습니다.

ObjectQuery<Contact> contacts =
      context.Contact
       .Where("it.ContactID = @ContactID",
         new ObjectParameter("ContactID", customerId))
        .Include("SalesOrderHeader.SalesOrderDetail")
        .Include("SalesOrderHeader.Address");

참고 항목

개념

EntityDataSource 컨트롤 구성

데이터 필터링(EntityDataSource)

EntityDataSource 디자이너

기타 리소스

Shaping Query Results (Entity Framework)