LINQ-我使用 order by 子句按升序排序以获取数据库中可用的所有状态,但它不起作用。这是代码:
public List<State> GetAllStates()
{
List<State> p;
p = (from a in _db.ProductImageMaps
where a.State != "" && a.State != null
select new State
{
Name = a.State
}).OrderBy(a=>a.Name).Distinct().ToList();
return p;
}