IQueryable上的 C# Foreach
我在以下代码中遇到 stackoverflow 异常...
IQueryable<MilestoneList> ml = from MilestoneList d in this.getDB().AsQueryable<MilestoneList>()
where d.Contains((Milestone)toDelete) == true
select d;
if (ml.Count() > 0)
{
foreach (MilestoneList m in ml)
{
m.Remove((Milestone)toDelete);
this.getDB().Store(m);
}
}
我的 MilestoneList 对象已实现 IEnumerable 和 IEnumerator。
但我认为循环遍历这些对象的列表应该不是问题。 有人有什么建议可以推动我找到解决方案吗?
根据要求提供更多信息。
更新&回答:
问题似乎出在 Contain 函数上。 这是一个令人尴尬的错误.. 对于您失去的时间深表歉意..
public bool Contains(Milestone m)
{
Activate(ActivationPurpose.Read);
return this._mList.Contains(m);
}
我忘记了参考我的内部列表。所以我通常创建了一个无限循环。
I'm getting stackoverflow exceptions on the following code...
IQueryable<MilestoneList> ml = from MilestoneList d in this.getDB().AsQueryable<MilestoneList>()
where d.Contains((Milestone)toDelete) == true
select d;
if (ml.Count() > 0)
{
foreach (MilestoneList m in ml)
{
m.Remove((Milestone)toDelete);
this.getDB().Store(m);
}
}
My MilestoneList object had IEnumerable and IEnumerator implemented.
But looping through a list of those objects shouldn't be problem I assume.
Anybody has any tips for pushing me in a direction towards a solution?
more info on request.
update & Answer :
The problem seems to be at the Contain function.
It was an embarrassing mistake.. sorry for your lost time..
public bool Contains(Milestone m)
{
Activate(ActivationPurpose.Read);
return this._mList.Contains(m);
}
I forgot the to refer to my internal list. So I generaly created an infinite loop.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新&回答:
问题似乎出在 Contain 函数上。这是一个令人尴尬的错误.. 对于您失去的时间深表歉意..
我忘记了参考我的内部列表。所以我通常创建了一个无限循环。
update & Answer :
The problem seems to be at the Contain function. It was an embarrassing mistake.. sorry for your lost time..
I forgot the to refer to my internal list. So I generaly created an infinite loop.