The app allows users to search by different categories. I would like to use a switch case instead of a bunch of ifs. The lamba expression does not accept the variable as it does not exist in the invoice_Master list. Is there a way to be able to use a variable that will equal what would be in the table? Note - This is using Entity Framework
This code works
                string searchValue = "";
                switch (searchBy)
                {
                    case "PONumber":
                        searchValue = "INVCE_31";
                        break;
                    case "SerialNumber":
                        searchValue = "ORDID_31";
                        break;
                    default:
                        return PartialView("InvoiceList", invoice_Master);
                }
                var results = invoice_Master.Where(m => m.INVCE_31== search).ToList();
                return PartialView("InvoiceList", results);
But this is what I want
                string searchValue = "";
                switch (searchBy)
                {
                    case "PONumber":
                        searchValue = "INVCE_31";
                        break;
                    case "SerialNumber":
                        searchValue = "ORDID_31";
                        break;
                    default:
                        return PartialView("InvoiceList", invoice_Master);
                }
                var results = invoice_Master.Where(m => m.searchValue == search).ToList();
                return PartialView("InvoiceList", results);
The only difference between the two is the second to bottom line where the lamba expression uses a variable instead of a defined item from the list.
