-3

代码有效:

var reports = repository.GetAll().ToList().
    Where(r => r.Documents.
                 Where(d => d.Reports.
                              Where(rw => rw.ID == reportID).Any()).Any()).
    ToList<IDocumentObjects>();

但是我不想用 ToList 这个代码调用一个错误:

var reports = repository.GetAll().
     Where(r => r.Documents.
                   Where(d => d.Reports.
                                 Where(rw => rw.ID == reportID).Any()).Any()).
     ToList<IDocumentObjects>();

错误:

成员访问'System.Collections.Generic.IList 1[IReport] Reports' of 'IDocument' not legal on type 'System.Collections.Generic.IList1[IDocument]。

问题:如何在 GetAll() 中不使用 ToList 创建此请求?

4

1 回答 1

1

您的导航属性使用接口而不是实体类型(例外提及IReportIDocument)。将其更改为实现并重试。EF 不支持接口。

于 2012-08-15T10:02:56.063 回答