public List <string> GetCategories(string ticketStr) { var db = new TicketContext(); DataTable dt; switch (ticketStr) { case "红雁池": dt = db.HyGetCategories(); break; default: dt = db.GetCategories(); break; } var result = new List <string>(); if (dt == null && dt.Rows.Count == 0) { return(result); } foreach (DataRow item in dt.Rows) { result.Add(item.Field <string>("lx")); } return(result.OrderBy(x => x).ToList()); }