osyris zosar

osyris zosar

  • 1.8k
  • 227
  • 5.3k

Creating multiple Page search/filtering system in best possible way

Apr 17 2021 11:15 PM
I know how to create single search on products
But how do I filter products base on multiple Fields
for example search on Title, price, brand and discription at the same time
 
What would be to most professional way to achive this
 
Single filter:

  1. public async Task<IActionResult> Index(string Title, string price, string discription string brand)  
  2.     {  
  3.         var products = from m in _context.Product  
  4.                        select m;  
  5.   
  6.         if (!string.IsNullOrEmpty(Title))  
  7.         {  
  8.             products = _context.Product.Where(x => x.Title.ToLower().Contains(Title.ToLower()));  
  9.               
  10.         }  
  11.         return View(await products.ToListAsync());  
  12.     }  
 
 

Answers (6)