【发布时间】:2015-01-05 04:42:13
【问题描述】:
var seasonPlayer = (from SeasonPlayer in db.SeasonPlayerSet
orderby SeasonPlayer.StatisticsPlayer.Average(x => x.STP_timeplay.Ticks) descending
select SeasonPlayer).ToList();
SeasonPlayer 有一个 StatisticsPlayer 的 ICollection,所以我想获得在球场上花费的平均时间,按 STP_timeplay 降序排列,这是 TimeSpan 的一个典型值。我无法通过 STP_timeplay 获取平均值,因为它不是小数,所以我尝试通过 Ticks 获取平均值。它抛出一个异常:
The specified type member 'Ticks' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
【问题讨论】:
标签: linq sql-order-by average timespan