无法将类型“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);




求教!
...全文
659 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用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);
目录 1 LINQ查询结果集 1 2 System.Array 数组 1 2.1 基于System.Array定义数组 1 2.2 基于类型定义数组 1 2.3 数组元素的清空 1 2.4 System.Array类静态成员 1 2.5 不用循环填充数组 1 2.6 数组类实例成员 2 3 System.Collections 集合 2 3.1 ArrayList 2 3.1.1 实例成员 2 3.1.2 静态成员 2 3.2 List 3 3.3 Hashtable 6 3.4 SortedList 6 3.5 SortedList 7 3.6 Queue 8 3.7 Stack 8 3.8 LinkedList 8 3.9 HashSet 9 4 System.Linq 10 4.1 System.Linq.Enumerable 10 4.2 System.Linq.Queryable 10 4.3 System.Linq.Lookup 10 4.4 System.Linq.Expressions.Expression 10 5 接口 10 5.1 IEnumerable 、IEnumerator 10 5.1.1 正常使用 10 5.1.2 C#的 yield 12 5.2 IEnumerable 12 5.3 IEnumerator 12 5.4 ICollection 12 5.5 ICollection 13 5.6 IList 13 5.7 IList 13 5.8 IEqualityComparer 13 5.9 IEqualityComparer 13 5.10 IDictionary 13 5.11 IDictionary 13 5.12 IDictionaryEnumerator 13 5.13 IComparer 13 5.13.1 接口方法说明 int Compare(object x, object y) 13 5.13.2 ArrayList.Sort (IComparer) 方法 13 5.14 IComparer 14 5.14.1 接口方法override int Compare(T x, T y)说明 14 5.14.2 List.Sort (IComparer) 方法 14 5.15 System.Linq.IGrouping 14 5.16 System.Linq.ILookup 14 5.17 System.Linq.IOrderedEnumerable 14 5.18 System.Linq.IOrderedQueryable 14 5.19 System.Linq.IOrderedQueryable 15 5.20 System.Linq.IQueryable 15 5.21 System.Linq.IQueryable 15 5.22 System.Linq.IQueryProvider 15 6 集合扩展方法 15 6.1 集合扩展方法的实现:一个Where的例子 15 6.2 延迟类 15 6.2.1 Select 选择 16 6.2.2 SelectMany 选择 16 6.2.3 Where 条件 16 6.2.4 OrderBy 排序升 17 6.2.5 OrderByDescending 排序降 17 6.2.6 GroupBy 分组 17 6.2.7 Join 联合查询 18 6.2.8 GroupJoin 18 6.2.9 Take 获取集合的前n个元素 19 6.2.10 Skip 跳过集合的前n个元素 19 6.2.11 Distinct 过滤集合中的相同项 19 6.2.12 Union 连接不同集合,自动过滤相同项 19 6.2.13 Concat 连接不同集合,不会自动过滤相同项 19 6.2.14 Intersect 获取不同集合的相同项(交集) 20 6.2.15 Except 从某集合中删除其与另一个集合中相同的项 20 6.2.16 Reverse 反转集合 20 6.2.17 TakeWhile 条件第一次不成立就跳出循环 20 6.2.18 SkipWhile 条件第一次不成立就失效,将后面的数据全取 20 6.2.19 Cast 将集合转换为强类型集合 21 6.2.20 OfType 过滤集合中的指定类型 21 6.3 不延迟(浅复本) 21 6.3.1 Single 集合中符合条件的唯一元素,浅复本 21 6.3.2 SingleOrDefault 集合中符合条件的唯一元素(没有则返回类型默认值),浅复本 21 6.3.3 First 集合的第一个元素,浅复本 21 6.3.4 FirstOrDefault 集合中的第一个元素(没有则返回类型默认值),浅复本 22 6.3.5 Last 集合中的最后一个元素,浅复本 22 6.3.6 LastOrDefault 集合中的最后一个元素(没有则返回类型默认值),浅复本 22 6.3.7 ElementAt 集合中指定索引的元素,浅复本 22 6.3.8 ElementAtOrDefault 集合中指定索引的元素(没有则返回类型默认值),浅复本 22 6.3.9 Contains 判断集合中是否包含有某一元素 22 6.3.10 Any 判断集合中是否有元素满足某一条件 22 6.3.11 All 判断集合中是否所有元素都满足某一条件 23 6.3.12 SequenceEqual 判断两个集合内容是否相同 23 6.3.13 Count 、LongCount集合中的元素个数 23 6.3.14 Average 、Sum集合平均值求和 23 6.3.15 Max、Min 集合最大值,最小值 24 6.3.16 Aggregate 根据输入的表达式获取一个聚合值 24 6.3.17 DefaultIfEmpty 查询结果为空则返回默认值,浅复本 24 6.3.18 ToArray 将集合转换为数组,浅复本 24 6.3.19 ToList 将集合转换为List集合,浅复本 25 6.3.20 ToDictionary 将集合转换集合,浅复本 25 7 Lambda表达式 25 7.1 例1(比效) 25 7.2 例2(多参) 27 7.3 例3(list.Where) 27 7.4 Lambda表达式中Lifting 28 8 QuerySyntax 查询语法 29 8.1 from in select 30 8.2 orderby 排序 30 8.3 group by into 分组 31 8.4 join in on equals 联合查询 33 8.5 into 汇总 33 9 DataSource 数据绑定 34

62,243

社区成员

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

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

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

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