我正在执行存储的proc sp_GetCustSurveys的System.Data.Objects.ObjectResult,然后我在遍历结果集。在主循环内部,我想创建一个项目的子集(具有相同id的项目列表):
using (MyObject_Surveys _db = new MyObject_Surveys ())
{
_db.CommandTimeout = 10000;
var rawSurveys = _db.sp_GetCustSurveys();
foreach (var survey in rawSurveys)
{
var surveyMultipleLangs = rawSurveys.Where(w => w.Id.Contains("123"));
foreach (var itm in surveyMultipleLangs)
{
var myName = itm.Name;
var myLanguage = itm.Language;
}
....
当我遍历子集时,我收到错误: "查询结果不能多次枚举"。请指教。谢谢。
答案 0 :(得分:0)
好的,明白了。我只需要实现我的ObjectResult,以便能够再次查询它: var rawSurveys = _db.sp_GetCustSurveys()。toList(); 它似乎有效。