我有一些东西让我绝对疯狂......
Public Function GetAccountGroups() As IList(Of AccountGroup)
Dim raw_account_groups As IList(Of AccountGroup)
raw_account_groups = _repository.GetAccountGroups().ToList()
Dim parents = (From ag In raw_account_groups _
Where ag.parent_id = 0 _
Select ag).ToList()
parents(0).sub_account_groups = (From sag In raw_account_groups _
Where sag.parent_id = 0 _
Select sag).ToList()
Dim sql_func As Func(Of AccountGroup, List(Of AccountGroup)) = Function(p) _
(From sag In raw_account_groups _
Where sag.parent_id = p.id _
Select sag).ToList()
parents.ForEach(Function(p) p.sub_account_groups = sql_func(p))
Return parents
End Function
线路parents.ForEach(Function(p) p.sub_account_groups = sql_func(p))
有这个错误...
未为类型“System.Collections.Generic.IList(Of st.data.AccountGroup)”和“System.Collections.Generic.List(Of st.data.AccountGroup)”定义运算符“=”。
但我真的看不出它与 Rob Connery 的这段代码有什么不同
public IList<Category> GetCategories() {
IList<Category> rawCategories = _repository.GetCategories().ToList();
var parents = (from c in rawCategories
where c.ParentID == 0
select c).ToList();
parents.ForEach(p =>
{
p.SubCategories = (from subs in rawCategories
where subs.ParentID == p.ID
select subs).ToList();
});
return parents;
}
编译完美...我做错了什么?
VB.Net 中的 Lambda 必须返回一个值,因此等号 ('=') 被解释为比较(以便 lambda 返回布尔值),而不是赋值。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)