0

我的视图 (XAML) 中有一个数据绑定网格,并且 Itemsource 指向一个 ReportsCollection。Reports 实体具有三个原语和一些复杂类型。这三个在数据网格中按预期显示。此外,Reports 实体具有 Store 类型的属性。当通过 GetReports 域方法加载报告时,我很快发现只返回原语,而不是某个深度的整个图。因此,由于我也想加载 Store 属性,所以我在我的域服务中进行了此更改:

public IQueryable<Report> GetReports()
{
    return this.ObjectContext.Reports.Include("Store");
}

从我在即时窗口中看到的内容来看,存储按预期加载,但是当返回给客户端时仍然被修剪。如何解决这个问题?

谢谢!

4

1 回答 1

1

使用 [Include] 装饰 ReportMetadata 类中的 Store 属性。

[MetadataTypeAttribute(typeof(Report.ReportMetadata))]
public partial class Report
{
    internal sealed class ReportMetadata
    {
        [Include]
        public Store Store;
    }
}
于 2010-03-12T16:26:42.343 回答