首页 新闻 会员 周边 捐助

这句SQL我改成LINQ后页面报错了,不知道哪有问题

0
悬赏园豆:20 [已关闭问题] 关闭于 2014-05-07 18:20

这是SQL语句:

SELECT HTTP_PATH, FILE_NAME ,FILE_NAME_SOURCE FROM
                     ( SELECT * FROM  UPLOAD WHERE SER_NO = :SerNo) WHERE ROWNUM <= 1 ORDER BY ROWNUM ASC

我改之后的LINQ:

var result = from u in ((Entities)this.DataContext).UPLOAD.Where(s => s.SER_NO == serno).Where((s, index) => index <= 1).Select((s, index) => new { s, index }).OrderBy(s => s.index)
                         select new { HTTP_PATH = u.s.HTTP_PATH, FILE_NAME = u.s.FILE_NAME, FILE_NAME_SOURCE = u.s.FILE_NAME_SOURCE };

报了这个错:
04:17:44 LINQ to Entities 不识别方法“System.Linq.IQueryable`1[<>f__AnonymousType20`2[EFDemoLite.Data.OralceEntities.UPLOAD,System.Int32]] Select[UPLOAD,<>f__AnonymousType20`2](System.Linq.IQueryable`1[EFDemoLite.Data.OralceEntities.UPLOAD], System.Linq.Expressions.Expression`1[System.Func`3[EFDemoLite.Data.OralceEntities.UPLOAD,System.Int32,<>f__AnonymousType20`2[EFDemoLite.Data.OralceEntities.UPLOAD,System.Int32]]])”,因此该方法无法转换为存储表达式。 在...

许大虾的主页 许大虾 | 初学一级 | 园豆:12
提问于:2014-05-04 16:22
< >
分享
所有回答(1)
0

你这个sql不是这样的吗?

SELECT HTTP_PATH, FILE_NAME ,FILE_NAME_SOURCE FROM
                     UPLOAD WHERE SER_NO = :SerNo WHERE ROWNUM <= 1 ORDER BY ROWNUM ASC

这样linq会简单些吧

Devin Mao | 园豆:596 (小虾三级) | 2014-05-07 17:20
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册