0
我有以下關係優化NHibernate的查詢
class Author
{
int Id;
}
class Publisher
{
int Id;
}
class Book
{
Publisher Publisher;
Author Author;
DateTime PublishDate;
}
我想優化以下查詢:
foreach (Publisher)
{
foreach (Author)
{
session.Query<Book>()
.Where(x=> x.Author.Id == Author.Id && x.Publisher.Id ==Publisher.Id)
.OrderByDescending(x=> x.PublishDate)
.Take(5);
}
}
我意識到,性能明智的這段代碼是可怕的,怎麼樣我可以改進它並在更少的查詢中獲得相同的結果嗎?
非常感謝!