【发布时间】:2010-11-05 06:53:16
【问题描述】:
此问题与a previous question of mine有关
这是我当前的代码
IEnumerable<Shape> Get()
{
while(//get implementation
yield return new Shape(//...
}
void Insert()
{
var actual = Get();
using (var db = new DataClassesDataContext())
{
db.Shapes.InsertAllOnSubmit(actual);
db.SubmitChanges();
}
}
我遇到了内存溢出,因为 IEnumerable 太大了。如何预防?
【问题讨论】:
标签: c# .net linq-to-sql ienumerable yield