あなたは MVC ソリューションを求めています。私が提供します。
インターフェイス ISearchable を実装する
interface ISearchable{
SearchResult Search(string query);
}
クラス SearchResult を実装する
public class SearchResult{
SearchResult(string title, string url, string description, int rank){
this.Title = title;
this.Url = url;
this.Description = description;
this.Rank = rank;
}
public string Title { get; set; }
public string Url { get; set; }
public string Description { get; set; }
public int Rank { get; set; }
}
ViewModel に ISearchable インターフェイスを実装させます。
public class MyViewModel : ISearchable{
public List<Article> Articles { get; set; }
#region ISearchable
public SearchResult Search(string query){
string title = "";
string url = "";
string description = "";
int rank = 0;
// Custom logic to search for an article
...
return new SearchResult(title, url, description, rank);
}
#endregion
}
ISearchable
ViewModel を に登録します。Application_Start
たとえば、 を使用しUnity
ます。
SearchController
アクションクエリを実装して持っています。
public ActionResult Query(SearchQueryModel model){
model.Search();
return View(model);
}
で、インターフェイスmodel.Search()
を実装する登録済みの ViewModel を検索し、ISearchable
最適な Whatsever Search API を使用します。または、API を使用しないでください。
現実には、どのような検索もすぐには役に立ちますが、役に立たなくなったときは、実装を壊さずに切り替えることができます。
「最高の ASP.NET MVC 検索ソリューション」を求められたことは承知しています。ソリューションの内部の仕組みや予算などがわからないため、特定の製品を選択することはできません.
ただし、厳密には ASP.NET MVC の観点からは、上記のシナリオにプラグインできるものは適切なはずです。それがあなたの法案に適合するかどうかなど...