我正在寻找建议/建议。我正在尝试优化一个长期运行的过程。这是最长的运行过程,每个调用1分钟48秒返回一个填充列表。我遍历每个请求有1000条记录,因此您可以想象几分钟可以累积多长时间。我已将所有其他方法的最优化速度设置为每1000秒少于10秒。我希望能够加快速度。
GetLoans()从数据库检索数据,并将其发送到GetLoanList()以创建要发送到静态Web服务的Collection。
GetRequestedWatches()返回一个类似“ 1,2”的字符串,因此非常快。
以'_'开头的变量是在实例化时加载的类级属性。
我尝试过“急切加载”和“延迟加载”。到目前为止,渴望加载是最好的选择。
任何建议将不胜感激。
private List<SBLead> GetLoanList(IEnumerable<LoanCategoryMonitor> loans)
{
return (loans.Where(selectedItem => selectedItem.Loan != null)
.Select(selectedItem => new SBLead
{
ApiKey = _settings.apiKey,
CrmId = selectedItem.LoanNumber.ToString(),
CrmName = _crmName,
LoanType = selectedItem.Loan.Loan_Type,
Email = selectedItem.Loan.abcBorrower?.EMail_Address,
FirstName = selectedItem.Loan?.Borr_First_Name,
LastName = selectedItem.Loan?.Borr_Last_Name,
Address = selectedItem.Loan?.Address,
City = selectedItem.Loan?.City,
State = selectedItem.Loan?.State,
Zip = selectedItem.Loan?.Zip,
Phone = string.Empty,
WatchTypes = GetRequestedWatches(selectedItem.Category.GetEnumFromString<Category>()),
UserEmail = _defaultLoanOfficerEmail,
UserName = _defaultLoanOfficerName
})).ToList();
}
public IEnumerable<LoanCategoryMonitor> GetLoans()
{
var loanCollection = _be.LoanCategoryMonitors
.Include(c => c.Loan)
.Where(r => r.ReadyForUpdate == true && r.LoanExtracts == null &&
r.Category != Category.None.ToString())
.AsNoTracking()
.ToList();
return loanCollection;
}