我必须从包含已定义(长)sessionId 的数据库表中选择所有行,其中 sessionId 行被索引。但它很慢,而且由于访问它的代码非常简单,我想知道问题出在哪里。下面是三层的代码:
var localPath = BusinessClient.Instance.Tracker.GetSpecifiedMilestonesInSessionObjects(milestonesInSession.SessionId).ToList();
public IQueryable<MilestonesInSession> GetSpecifiedMilestonesInSessionObjects(long sessionId)
{
var query = from m in _milestonesInSessionRepository.GetAll()
where m.SessionId == sessionId
select m;
return query;
}
public IQueryable<Model.Tracker.MilestonesInSession> GetAll()
{
var query = from milestoneSession in _dataContext.Repository<Linq.TrackerMilestonesInSession>()
select new Model.Tracker.MilestonesInSession
{
MilestoneId = milestoneSession.MilestoneId,
CreatedDate = milestoneSession.CreatedDate,
SessionId = milestoneSession.SessionId,
ProductId = milestoneSession.ProductId,
TrackerId = milestoneSession.TrackerId,
StatusId = milestoneSession.StatusId,
BankId = milestoneSession.BankId
};
return query;
}
这里附上使用 ANTS 的表演截图:
表示层
业务层
数据访问层