- NET打开的DataReader 4.5
我得到上述错误(主题行)当我部署到生产服务器和迭代位置在foreach。为了让它在生产服务器上工作,我必须转换为数组,即var locationArray = locations.ToArray();并重复locationArray。必须关闭第一
所以我的问题是当在测试(在VS2013中调试时运行本地)我正在运行一个SQLExpress实例和在PRODUCTION我正在运行一个完全成熟的SQLServer。然而,为什么迭代位置在测试中不产生错误,但是在PRODUCTION中这样做?
public IQueryable<State> StatesInCountryGet(long aCountryId)
{
List<State> result = new List<State>();
using (DataRepository dataRepository = DataRepository.Instance())
{
//#TODO: Find a better way to do a GROUP BY
IQueryable<LocationsMapping> locations = dataRepository.Query<LocationsMapping>(r => r.CountryId == aCountryId);
var locationArray = locations.ToArray(); //Why do I need to do this?
foreach (LocationsMapping locationMapping in locationArray)
{
//Add the state if we don't have it already
if (!result.Exists(r => r.Id == locationMapping.StateId))
{
result.Add(locationMapping.State);
}
}
}
return result.AsQueryable();
}
请将您正在连接到PRODUCTION服务器的代码添加到您的问题中。问题在那里。 –
在连接字符串中是否有多个活动的结果集= true? –