我已经写了我认为是非常可靠的Linq语句,但是这会在执行时获得2到5秒的等待时间。有没有人想过如何加快速度?在Linq查询上特别慢的数据库响应时间
t.states = (from s in tmdb.tmZipCodes
where zips.Contains(s.ZipCode) && s.tmLicensing.Required.Equals(true)
group s by new Licensing {
stateCode = s.tmLicensing.StateCode,
stateName = s.tmLicensing.StateName,
FIPSCode = s.tmLicensing.FIPSCode,
required = (bool)s.tmLicensing.Required,
requirements = s.tmLicensing.Requirements,
canWorkWhen = s.tmLicensing.CanWorkWhen,
appProccesingTime = (int) s.tmLicensing.AppProcessingTime
}
into state
select state.Key).ToList();
我把它改为其通过执行不同的查询,使我的工作编组运行几乎瞬间两个阶段的查询,但在我看来,这是一个有点直觉上有跑这么多比单个查询更快。
有时,当你复制并粘贴你的代码时,你忽略了一些细节。我有另一个功能,填充许可对象,我只是从中剥离了代码。 – thaBadDawg 2009-01-17 00:00:30