私は次のようなクラスを持っています:
public class Category
{
public int CategoryId { get; set; }
[Required]
public string Name { get; set; }
[NotMapped]
public int ProductCount { get; set; }
public virtual IEnumerable<Product> Products { get; set; }
}
現在、次のようなクエリがあります。
context.Categories.SortBy(sortByExpression).Skip(startRowIndex).Take(maximumRows)
カテゴリグリッドにProductCountフィールドを含める必要があります。このLINQクエリを拡張して、Productコレクション全体を読み込まずにProductCountプロパティを取得することはできますか?古き良きSQLを使用してサブクエリでこれを行うことができますが、LINQを使用して困惑しています。
ありがとう