AspNetCore/Razor-Mvc/Mvc.DataFiltering/Controllers/OrderController.cs
/// <summary>
/// This action is called when user clicks on "Apply" button in FilterBar or other data-filtering widget
/// </summary>
/// <returns>IActionResult which contains a partial view with the filtered result set</returns>
This action is called when user clicks on "Apply" button in FilterBar or other data-filtering widget
This action is called when user clicks on " Apply " button in FilterBar or other data - filtering widget
[HttpPost("models/{modelId}/fetch")]
        public async Task<IActionResult> ApplyQueryFilter(string modelId, string queryId)
        {
            await _eqManager.ReadRequestContentFromStreamAsync(modelId, Request.Body);
            var orders = _dbContext.Orders
                      .Include(o => o.Customer)
                      .Include(o => o.Employee)
                      .AsQueryable();
            var text = _eqManager.ClientData.TryGetValue("text", out var textObj) ? textObj.ToString() : "";
            if (!string.IsNullOrEmpty(text)) {
                var options = new FullTextSearchOptions
                {
                    Depth = 2,
                    Filter = (propInfo) =>
                    {
                        if (propInfo.DeclaringType == typeof(Order))
                        {
                            return propInfo.PropertyType == typeof(Customer) || propInfo.PropertyType == typeof(Employee);
                        }
                        if (propInfo.PropertyType == typeof(string)) {
                            if (propInfo.DeclaringType == typeof(Customer)) {
                                return propInfo.Name == "Country" || propInfo.Name == "ContactName";
                            }
                            if (propInfo.DeclaringType == typeof(Employee)) {
                                return propInfo.Name == "FirstName" || propInfo.Name == "LastName";
                            }
                        }
                        return false;
                    }
                };
                orders = orders.FullTextSearchQuery<Order>(text, options);
            }
            orders = orders.DynamicQuery<Order>(_eqManager.Query);
            var list = orders.ToPagedList(_eqManager.Chunk.Page, 15);
            ViewData["Text"] = text;
            return View("_OrderListPartial", list);
        }
[ HttpPost ( " " ) ] public async Task < IActionResult > ApplyQueryFilter ( string modelId , string queryId ) { await _eqManager . ReadRequestContentFromStreamAsync ( modelId , Request . Body ) ; var orders = _dbContext . Orders . Include ( o => o . Customer ) . Include ( o => o . Employee ) . AsQueryable ( ) ; var text = _eqManager . ClientData . TryGetValue ( " " , out var textObj ) ? textObj . ToString ( ) : " " ; if ( ! string . IsNullOrEmpty ( text ) ) { var options = new FullTextSearchOptions { Depth = 2 , Filter = ( propInfo ) => { if ( propInfo . DeclaringType == typeof ( Order ) ) { return propInfo . PropertyType == typeof ( Customer ) || propInfo . PropertyType == typeof ( Employee ) ; } if ( propInfo . PropertyType == typeof ( string ) ) { if ( propInfo . DeclaringType == typeof ( Customer ) ) { return propInfo . Name == " " || propInfo . Name == " " ; } if ( propInfo . DeclaringType == typeof ( Employee ) ) { return propInfo . Name == " " || propInfo . Name == " " ; } } return false ; } } ; orders = orders . FullTextSearchQuery < Order > ( text , options ) ; } orders = orders . DynamicQuery < Order > ( _eqManager . Query ) ; var list = orders . ToPagedList ( _eqManager . Chunk . Page , 15 ) ; ViewData [ " " ] = text ; return View ( " " , list ) ; }
This action is called when user clicks on "Apply" button in FilterBar or other data-filtering widget
This action is called when user clicks on " Apply " button in FilterBar or other data - filtering widget
//read full-text search text // filter to use search for string fields we chose
IActionResult which contains a partial view with the filtered result set
IActionResult which contains a partial view with the filtered result set
modelId
string
queryId
string