日期:2014-05-20 浏览次数:20795 次
RefreshLinQDataContext dataContext = new RefreshLinQDataContext(); dataContext.DeferredLoadingEnabled = false;//防止foreach时到数据库做增量检查 var _DeviceInfo = dataContext.DeviceInfo.Where(v => v.Stauts == 2).OrderBy(v => v.InfoID).ToList(); var _DeviceParam = dataContext.DeviceParameter.ToList().GroupBy(v => v.InfoID).AsParallel().OrderBy(v => v.Key); var _DeviceParamProperty = dataContext.DeviceParameterProperty.ToList().GroupBy(v => v.DeviceParamID).AsParallel().OrderBy(v => v.Key); //到这里用了2秒左右 foreach (var di in _DeviceInfo) { di.DeviceParameter.AddRange(_DeviceParam.Single(v => v.Key == di.InfoID)); var dsfs = _DeviecSafeTime.SingleOrDefault(v => v.Key == di.InfoID); foreach (var dp in di.DeviceParameter) { dp.DeviceParameterProperty.AddRange(_DeviceParamProperty.Single(v => v.Key == dp.DeviceParamID)); } }