【发布时间】:2013-04-11 03:14:50
【问题描述】:
我在 c# 4 中有以下代码,我正在尝试使用 linq 进行排序、分组。
IList<Component> components = Component.OrganizationalItem.OrganizationalItem.Components(true);
IEnumerable<Component> baggage = components.Where(x => x.IsBasedOnSchema(Constants.Schemas.BaggageAllowance.ToString()))
.OrderBy(x => x.ComponentValue("name").StringValue("Code"))
.GroupBy(x => x.ComponentValue("name").StringValue("Code"));
在上面的示例中,当我尝试使用GroupBy 时出现错误,请参见下文:
无法将类型“
System.Collections.Generic.IEnumerable<System.Linq.IGrouping<string,Tridion.ContentManager.ContentManagement.Component>>”隐式转换为“System.Collections.Generic.IEnumerable<Tridion.ContentManager.ContentManagement.Component>”。存在显式转换(您是否缺少演员表?)*
【问题讨论】:
-
“它给出了错误”是从来没有足够详细。您应该始终给出编译器错误或异常等。