【发布时间】:2012-05-31 10:02:23
【问题描述】:
知道为什么 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());
相同的结果,没有排序...
我确实有解决方法,但只是想知道缺少什么......
任何建议将不胜感激:-)
【问题讨论】:
标签: linq entity-framework sql-order-by iqueryable