2011-09-29 2 views
0

나는 두 가지 레벨을 수행 할 수 있지만 treeviews에서 머리를 쓰려고 노력하고 있지만 세 번째 레벨을 추가하는 것이 어려워졌습니다. 나는 당신이 3 번째 계층 적 템플릿을 만들었다 고 추측하지만, 이것이 어떻게 로딩되어 있는지 모르겠습니다. AdventureWorks 데이터베이스를 샘플 데이터로 사용하고 있습니다.WCF RIA 서비스를 사용하여 마스터 세부 정보 데이터 (2 계층 이상)를로드하는 방법

Product, ProductCategory 및 ProductSubCategory 테이블을 사용하고 있습니다.

내 메타 데이터는 다음과 같습니다. (나는 두 개의 쿼리를로드하는 방법을 이해하는 문제에 봉착 곳이다) 뒤에

public IQueryable<Product> GetProduct() 
{ 
    return this.ObjectContext.Product; 
} 

public IQueryable<ProductCategory> GetProductCategory() 
{ 
    return this.ObjectContext.ProductCategory.Include("ProductSubcategory"); 
} 

public IQueryable<ProductSubcategory> GetProductSubcategory() 
{ 
    return this.ObjectContext.ProductSubcategory.Include("Product"); 
} 

내 코드 : (단지 흥미로운 비트)

public partial class Product 
{ 
    public string Name { get; set; } 

    public int ProductID { get; set; } 

    public string ProductNumber { get;set; } 

    public ProductSubcategory ProductSubcategory { get; set; } 

    public Nullable<int> ProductSubcategoryID { get; set; } 
} 

public partial class ProductCategory 
{ 
    public string Name { get; set; } 

    public int ProductCategoryID { get; set; } 

    [Include] 

    [Composition] 

    public EntityCollection<ProductSubcategory> ProductSubcategory { get; set; } 
} 

public partial class ProductSubcategory 
{ 
    public string Name { get; set; } 

    [Include] 

    [Composition] 

    public EntityCollection<Product> Product { get; set; } 

    public ProductCategory ProductCategory { get; set; } 

    public int ProductCategoryID { get; set; } 

    public int ProductSubcategoryID { get; set; } 

내 쿼리는 다음과 같다. ProductCategory 아래의 ProductSubCategory에서 Products를 반환하고 싶습니다. 당신이 나무를 구축하려는 경우, 작동 있을지

{ 
    return this.ObjectContext.ProductCategory.Include("ProductSubcategory").Include("ProductSubcategory.Product"); 
} 

는 나도 몰라,하지만 데이터를 포함한다 :

public partial class Tree : Page 
{ 
    public Tree() 
    { 
     InitializeComponent(); 

     AdventureWorksContext ads = new AdventureWorksContext(); 

     trvTree.ItemsSource = ads.ProductCategories; 

     ads.Load(ads.GetProductCategoryQuery());   
    } 
} 

답변

0

시도는 다음과 같은 당신의 GetProductCategory 쿼리를 수정 필요에 따라.