无法将类型“System.Linq.IQueryable”隐式转换为“System.Linq.IOrderedQueryabl

www61550125 2012-01-29 12:45:31
CS0029: 无法将类型“System.Linq.IQueryable<AnonymousType#1>”隐式转换为“System.Linq.IOrderedQueryable<AnonymousType#1>”

var source = from a in this.db.Reader_JD_Comment
join b in this.db.Product on a.id equals b.id
select new
{
id = a.id,
pj = a.pj,
istj = a.istj,
parentid = a.parentid,
qd = a.qd,
isdel = a.isdel,
eppName = b.eppName,
buyFrom = a.buyFrom,
smallclass = a.smallclass,
username = a.username,
commentType = a.commentType,
yd = a.yd,
fabudate = a.fabudate,
fs = a.fs,
smallpic = b.smallpic,
spid = a.spid,
pinpai = b.pinpai,
price = b.price,
p_name = b.p_name,
pricewebCount = b.pricewebCount,
commentAVG = b.commentAVG,
commentCount = b.commentCount,
sellcount = b.sellcount,
smallpic80 = b.smallpic80
} into c
where !c.isdel == (c.fabudate < DateTime.Now)
where (c.commentType == 0) && (c.smallclass == this.id)
where c.parentid == 0
orderby c.fabudate descending
select c;
string strPost = "_" + this.id + "_0";
int iRecordCount = 0;
short count = 20;
short iPageCurrent = 1;
iRecordCount = source.Count();
iPageCurrent = Convert.ToInt16((iPageCurrent < 1) ? 1 : ((int)iPageCurrent));
int num4 = (iPageCurrent - 1) * count;
source = source.Skip(num4).Take(count); this.rptComment.DataSource = source;
this.rptComment.DataBind();
this.lblPage.Text = common.NetPageWJT(iRecordCount, count, iPageCurrent, "Comment", strPost);


disProduct.aspx.cs 行: 65

行: 65 :source = source.Skip(num4).Take(count);




求教!
...全文
683 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
jayrao5566 2012-01-29
  • 打赏
  • 举报
回复

source =source.orderby(c=> c.fabudate)
beyond_me21 2012-01-29
  • 打赏
  • 举报
回复
source = source.Skip(num4).Take(count).ToList();
回头是岸 2012-01-29
  • 打赏
  • 举报
回复
source = source.Skip(num4).Take(count); this.rptComment.DataSource = source;
把你这段改成:
this.rptComment.DataSource=source.Skip(num4).Take(count);
这样不就可以!
www61550125 2012-01-29
  • 打赏
  • 举报
回复
自己再顶一下
www61550125 2012-01-29
  • 打赏
  • 举报
回复
还是同样一摸一样错误。

代码都替换过
threenewbee 2012-01-29
  • 打赏
  • 举报
回复
var source = from a in this.db.Reader_JD_Comment
join b in this.db.Product on a.id equals b.id
select new
{
id = a.id,
pj = a.pj,
istj = a.istj,
parentid = a.parentid,
qd = a.qd,
isdel = a.isdel,
eppName = b.eppName,
buyFrom = a.buyFrom,
smallclass = a.smallclass,
username = a.username,
commentType = a.commentType,
yd = a.yd,
fabudate = a.fabudate,
fs = a.fs,
smallpic = b.smallpic,
spid = a.spid,
pinpai = b.pinpai,
price = b.price,
p_name = b.p_name,
pricewebCount = b.pricewebCount,
commentAVG = b.commentAVG,
commentCount = b.commentCount,
sellcount = b.sellcount,
smallpic80 = b.smallpic80
} into c
where !c.isdel == (c.fabudate < DateTime.Now)
where (c.commentType == 0) && (c.smallclass == this.id)
where c.parentid == 0
orderby c.fabudate descending
select c;
=>
var source = (from a in this.db.Reader_JD_Comment
join b in this.db.Product on a.id equals b.id
select new
{
id = a.id,
pj = a.pj,
istj = a.istj,
parentid = a.parentid,
qd = a.qd,
isdel = a.isdel,
eppName = b.eppName,
buyFrom = a.buyFrom,
smallclass = a.smallclass,
username = a.username,
commentType = a.commentType,
yd = a.yd,
fabudate = a.fabudate,
fs = a.fs,
smallpic = b.smallpic,
spid = a.spid,
pinpai = b.pinpai,
price = b.price,
p_name = b.p_name,
pricewebCount = b.pricewebCount,
commentAVG = b.commentAVG,
commentCount = b.commentCount,
sellcount = b.sellcount,
smallpic80 = b.smallpic80
} into c
where !c.isdel == (c.fabudate < DateTime.Now)
where (c.commentType == 0) && (c.smallclass == this.id)
where c.parentid == 0
select c).OrderByDescending(c => c.fabudate).ToList();
www61550125 2012-01-29
  • 打赏
  • 举报
回复
楼上的:
source = source.ToList().Skip(num4).Take(count);

同样错误。
threenewbee 2012-01-29
  • 打赏
  • 举报
回复
source = source.Skip(num4).Take(count);
=>
source = source.ToList().Skip(num4).Take(count);

62,256

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧