System.Collections.Generic.List <plate>'不包含'Time'的定义,也没有扩展方法'Time'</plate>

时间:2012-03-23 20:04:42

标签: .net linq

这是我正在尝试执行的LINQ语句

var usersQuery =
from user in Model.Users
select user.Plates;

var platesQuery =
from plate in usersQuery
group plate by plate.Time into grouping
select grouping;

我收到以下错误

System.Collections.Generic.List<AllYourPlates.Domain.Entities.Plate>' does not contain a definition for 'Time' and no extension method 'Time' accepting a first argument of type 'System.Collections.Generic.List<AllYourPlates.Domain.Entities.Plate>' could be found (are you missing a using directive or an assembly reference?

我无法弄清问题是什么。

1 个答案:

答案 0 :(得分:2)

usersQueryIEnumerable<IEnumerable<Plate>>您可以在platesQuery中对此进行纠正:

var platesQuery = from plates in usersQuery
                  from plate in plates
                  group plate by plate.Time into grouping
                  select grouping;

或者缩小初始结果,以便改为IEnumerable<Plate>

var usersQuery = from user in Model.Users
                 from plate in user.Plates
                 select plate;