var report = await db.Journal.AsNoTracking().Join(db.Users.AsNoTracking(),
(x => x.ClientUserId),
(y => y.UserId),
((x, y) => new { Journal = x, Users = y }))
.Where(z => z.Journal.TotalTime >= 1 && z.Users.UserCompanies_id == companyId &&
z.Journal.DoneAt >= fromDateTime && z.Journal.DoneAt <= toDateTime)
.GroupBy(e => e.Users.UserId)
.Select(e => new ReportViewModel()
{
UserId = e.Key,
TimeSpendCCM = e.Sum(s => s.Journal.TotalTime),
//DateOfBirthday = e.FirstOrDefault().Users.DateOfBirthday
}).ToListAsync();
问题出在DateOfBirthday。这行代码需要4秒钟!!! 当我删除DateOfBirthday时,所有请求大约需要150-200ms。当我再次添加DateOfBirthday时,请求大约需要4秒钟。我在做什么错了?
数据库-MSSQL,ORM-实体框架