知道为什么 LINQ OrderBy 在以下代码中不起作用(没有错误,但方法不排序...)
首先是我自己的类型
public class IQLinksView
{
public int id { get; set; }
public int catid { get; set; }
public int? viewed {get;set;}
public string name {get;set;}
public string desc {get;set;}
public string url {get;set;}
public string pic {get;set;}
public string cat {get;set;}
}
然后查询:
IQueryable<IQLinksView> newView =
from links in this.emContext.tbl_otherlinks
select new IQLinksView { id = links.pklinkid, catid =
links.tbl_catgeory.pkcategoryid, viewed = links.linkviewed, name = links.linkname,
desc = links.linkdesc, pic = links.linkpicture, url = links.linkurl, cat =
links.tbl_catgeory.categoryname };
直到这里一切都很好:-),但是然后
newView.OrderBy(x => x.viewed);
只是没有改变任何东西,...页面正在加载结果显示...但没有排序...嗅探
我尝试使用(创建比较器对象...):
newView.OrderBy(x => (Int32)x.viewed, new CompareIntegers());
结果一样,没有排序...
我确实有解决方法,但只是想知道缺少什么......
任何建议将不胜感激,非常感谢:-)