直接上代碼:
db.GetList<Draw2D>(x => x.ProductId == id && x.EditionNo == no) .OrderBy(x => x.CreateTime.Desc()) .ToList();
這個無法排序!!!
return db.GetList<Draw2D>(x => x.ProductId == id && x.EditionNo == no) .OrderByDescending(x => x.CreateTime) .ToList();
這個可以!
錯誤原因:
之前公司SDK是那樣封裝的,現在回歸LINQ的原來寫法,不需要畫蛇添足。。。。
OrderBy默認就是正序不需要再寫```Asc()或Desc()```,如果要倒序排,就用OrderByDescing()
var lists = db.GetList<Draw2D>(x => x.ProductId == id) .OrderBy(x => x.EditionNo) //這里把 .Asc() 去掉即正常 .ThenBy(x => x.CreateTime);