次のような結果を作成したいと思います。カウント (検索) || 2 つの Entity Framework ベースのクラスに基づくCategoryName :
public class Category
{
// Primary properties
public int Id { get; set; }
public string Name { get; set; }
public string SearchPreviewControllerAction { get; set; }
}
public class Search
{
// Primary properties
public int Id { get; set; }
public string SearchTitle { get; set; }
public string SearchStandard { get; set; }
public int CategoryId { get; set; }
// Navigation properties
public virtual Category Category { get; set; }
}
「Aston Martin」という単語を含むすべてのカテゴリで検索される「Aston Martin」のような検索に基づいて検索結果を返す SearchPreview メソッドを既に作成しました。
ここでの課題は、「Aston Martin」というキーワードを検索した後、「Auto: 2 | Seeling point: 3 | Shop: 2」のようなカウントを含むキーワードが含まれるカテゴリを返すメソッドを構築することです。
検索エントリの数をカウントするために各カテゴリのクエリを回避しようとしています。既に実行されている SearchPreview メソッドを取得し、それに含まれるGroupByカテゴリを抽出するGroupByソリューションを見つけたいと思います。
SearchPreviewListCategoriesViewModel
Automapper を使用してモデルからマッピングするために ViewModelを使用しています。
public class SearchPreviewListCategoriesViewModel
{
public int CategoryID { get; set; }
public string Name { get; set; }
public string SearchPreviewControllerAction { get; set; }
public int SearchCount { get; set; }
}
誰かがこれについて私を助けてくれることを願っています。
ありがとうございました。
よろしく、
パトリック。