Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion BenchmarkService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,36 @@ public List<AuthorDTO_OptimizedStruct> GetAuthors_Optimized_Struct1()
.Take(2)
.ToList();
}

[Benchmark]
public List<AuthorDTO_OptimizedStruct> GetAuthors_Optimized_Struct_Join()
{
using var dbContext = new AppDbContext();

var date = new DateTime(1900, 1, 1);

return dbContext.Authors
.Where(x => x.Country == "Serbia" && x.Age == 27)
.OrderByDescending(x => x.BooksCount)
.Take(2)
.Join(dbContext.Users, a => a.UserId, u => u.Id, (a, u) =>
new AuthorDTO_OptimizedStruct
{
FirstName = u.FirstName,
LastName = u.LastName,
Email = u.Email,
UserName = u.UserName,
Age = a.Age,
Country = a.Country,
Books = a.Books.Where(b => b.Published.Year < 1900)
.Select(b =>
new BookDTO_OptimizedStruct
{
Title = b.Name,
PublishedYear = b.Published.Year
})
})
.ToList();
}
}
}
}