Rishi Tiwari

Rishi Tiwari

  • 1.4k
  • 294
  • 570

How to bind Table data with related filters in IQueryable method

Jul 25 2020 12:44 AM
I have created this method need to access in my code
 
This is a my repositoty calss method
  1. public IQueryable<Job> GetJobs(string q = ""int pageIndex = 1, int pageCount = 20, JobsSortOptions sortBy = JobsSortOptions.jobId, JobStatus jobStatus = JobStatus.active, JobsSortByDate sortByDate = JobsSortByDate.date)  
  2. {  
  3. IQueryable<Job> jobs = from j in _context.Jobs  
  4. select j;  
  5. if (!String.IsNullOrEmpty(q))  
  6. {  
  7. jobs = jobs.Where(j => j.JobTitle.Contains(q)  
  8. || j.JobId.ToString().Contains(q)  
  9. || j.ReqQual.Contains(q));  
  10. }  
  11. switch (q)  
  12. {  
  13. case "name_desc":  
  14. jobs = jobs.OrderByDescending(j => j.JobId);  
  15. break;  
  16. case "Date":  
  17. jobs = jobs.OrderBy(j => j.JobId);  
  18. break;  
  19. case "date_desc":  
  20. jobs = jobs.OrderByDescending(j => j.OpenDt);  
  21. break;  
  22. }  
  23. //(pageIndex, pageCount)  
  24. return jobs;  
  25. // var getJobDetails = _context.Jobs.Where(j => j.JobTitle.Contains(q));  
  26. //throw new NotImplementedException();  
  27. }  

Answers (4)