Мне любопытно, куда в цепочке вызовов следует включать call при использовании Entity Framework. Рассмотрим следующий метод:
// sample usage from service layer
// _customerRepository.Paginate(1, out totalRecords, 25, "DateJoined DESC, AmountSpent", "DateJoined >= '2009-02-01'", "Invoices, Refunds");
public virtual IQueryable<T> Paginate(int page, out int total, int pageSize, string sort = "Id", string filter = null, string includes = null)
{
IQueryable<T> query = DatabaseSet;
total = query.Count(); // get total # of records (required for pagination)...
var skipTo = GetValidSkipCount(page, total, pageSize);
if (!String.IsNullOrWhiteSpace(filter))
{
query.Where(filter);
}
// should includes be before filtering?
// should query.Count() be called after query.Include?
// does it matter?
if (!String.IsNullOrWhiteSpace(includes))
{
query.IncludeMany(includes); // my own extension that takes comma separated string of entities to include
}
return query.OrderBy(sort).Skip(skipTo).Take(pageSize);
}
Мои вопросы: