當我收到此錯誤錯誤運行LINQ查詢
"{"There is already an open DataReader associated with this Command which must be closed first."}"
下面是關於它的錯誤代碼。
var summaryViewModel = new YogaSpaceSummaryViewModel
{
SpaceImage = (from u in space.Images orderby u.Ordering ascending select u.ImageThumbnail).First(),
Title = space.Overview.Title,
SpaceId = space.YogaSpaceId,
DateCreated = space.DateCreated.ToShortDateString(),
StepsToList = space.StepsToList,
Status = space.Status
};
這段代碼的哪一部分這裏
YogaSpaceOverviewViewModel overviewViewModel = new YogaSpaceOverviewViewModel();
foreach (YogaSpace space in yogaSpaces)
{
var summaryViewModel = new YogaSpaceSummaryViewModel
{
SpaceImage = (from u in space.Images orderby u.Ordering ascending select u.ImageThumbnail).First(),
Title = space.Overview.Title,
SpaceId = space.YogaSpaceId,
DateCreated = space.DateCreated.ToShortDateString(),
StepsToList = space.StepsToList,
Status = space.Status
};
overviewViewModel.YogaSpaceSummarys.Add(summaryViewModel);
}
正如消息所示,請檢查您的任何以前打開/使用過的DataReader是否已正確關閉。 – MusicLovingIndianGirl
我該如何檢查? – user1186050
發佈DB連接的代碼 – MusicLovingIndianGirl