这是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]]])”,因此该方法无法转换为存储表达式。 在...
你这个sql不是这样的吗?
SELECT HTTP_PATH, FILE_NAME ,FILE_NAME_SOURCE FROM
UPLOAD WHERE SER_NO = :SerNo WHERE ROWNUM <= 1 ORDER BY ROWNUM ASC
这样linq会简单些吧