Created
September 5, 2017 14:26
-
-
Save Alexei000/9830c51f0376485180355938a0d8e449 to your computer and use it in GitHub Desktop.
Medium article - direct fetch with eager loading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var envIds = new List<int> {5}; | |
DateTime fromDate = DateTime.Now.AddDays(-7).Date; | |
DateTime toDate = DateTime.Now.Date.AddDays(1).AddSeconds(-1); | |
var results = DataAccess.ImportingSystemTestResultRepository.All | |
.Include(tr => tr.ImportingSystemTestRunTime) | |
.Include(tr => tr.ImportingSystemTestQueue) | |
.Include(tr => tr.ImportingSystemTest) | |
.Include(tr => tr.ImportingSystem) | |
.Include(tr => tr.Environment) | |
.Include(tr => tr.AppUser) | |
.Select(tr => new | |
{ | |
tr.ImportingSystemTestResultId, | |
tr.EnteredTimestamp, | |
tr.RunTimestamp, | |
tr.ImportingSystemTestId, | |
tr.EnvironmentId, | |
tr.ImportingSystemTestExecutionStatusId, | |
tr.ImportingSystemTestQueue.RequestId, | |
tr.ImportingSystemTestRunTime.FirstOrDefault().DurationMs, | |
tr.ImportingSystemTest.TestName, | |
tr.ImportingSystem.ImportingSystemName, | |
tr.Environment.Name, | |
FullName = tr.AppUser.LastName + " " + tr.AppUser.FirstName | |
}) | |
.Where(x => x.EnteredTimestamp >= fromDate && x.EnteredTimestamp <= toDate) | |
.Take(500) | |
.ToList(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment