Result of LINQ Query in MVC SelectList as Value and Text - not working
问题 I am trying to use the result of a LINQ Query to populate a SelectList in a MVC 5 application. The LINQ query returns customer IDs. Model public partial class Pricelist { public int CustomerID { get; set; } public int SelectedCustomer { get; set; } public Pricelist(int customerID, int selectedCustomer) { } } View @Html.DropDownList("custList") Controller (1) var query = ((from s in db.Pricelists select s.CustId).Distinct()).ToList(); int i = 1; List<Pricelist> CustomerList = new List