SearchPreviewControllerAction

SearchPreviewControllerAction

本文介绍了需要MVC帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想建立一个结果,如: CategoryID || 计数(搜索) ||
CategoryName 基于两个基于实体框架的课程:


   

   公共课类别

    {

        //主要属性

        public int Id {get;组; }¥b $ b        public string  Name {get;组; }¥b $ b        public string SearchPreviewControllerAction {get;组; }¥b $ b    }


   公共课搜索

    {

        //主要属性

        public int Id {get;组; }¥b $ b        public string SearchTitle {get;组; }¥b $ b        public string SearchStandard {get;组; }¥b $ b        public int CategoryId {get;组; }


        //导航属性

       公共虚拟类别类别{get;组; }¥b $ b    }


   我已经制作了一个SearchPreview方法,该方法根据类似"阿斯顿马丁"的搜索返回搜索结果。这将在所有类别中找到"阿斯顿马丁"字样。


 现在的挑战是建立一种方法,在搜索关键字"阿斯顿马丁"之后返回,其中包括计数的那些关键字,例如"Auto:2 |"。剥离点:3 |购物:2"


 我试图避免查询每个类别来计算搜索条目的数量,我想找到一个GroupBy解决方案,它已经执行了SearchPreview方法并提取它包含的GroupBy类别。


 我正在使用ViewModel  SearchPreviewListCategoriesViewModel使用Automapper从模型中进行映射:


   公共类SearchPreviewListCategoriesViewModel

    {

        public int CategoryID {get;组; }¥b $ b        public string Name {get;组; }¥b $ b        public string SearchPreviewControllerAction {get;组; }¥b $ b        public int SearchCount {get;组; }¥b $ b     }


 希望索索可以帮助我。


 谢谢。


 问候,


  Patrick。

解决方案

Hi,

I would like to build a result like: CategoryID || Count(Searches) ||CategoryName based on two Entity Framework based classes:

   

    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; }
    }

   I already made a SearchPreview method that returns the Searches based on a search like "Aston Martin" that will find in all categories with the words "Aston Martin".

  The challenge now is to build a method that returns, after the Search of the keywords "Aston Martin", in which categories there are those keywords including the count, like "Auto: 2 | Seeling point: 3 | Shop: 2"

  I am trying to avoid a query for each category to count the number of Searches entry, and I would like to find a GroupBy solution, that takes the SearchPreview method already executed and extract the GroupBy Categories that it contains.

  I am using the ViewModel SearchPreviewListCategoriesViewModel to map from the models using Automapper:

    public class SearchPreviewListCategoriesViewModel
    {
        public int CategoryID { get; set; }
        public string Name { get; set; }
        public string SearchPreviewControllerAction { get; set; }
        public int SearchCount { get; set; }
     }

  Hope somoeone can help me on this.

  Thank you.

  Regards,

 Patrick.

解决方案


这篇关于需要MVC帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 05:03