首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

linq分页有关问题

2012-02-07 
linq分页问题使用linq 分页是的时候当到第二页的时候就报错。错误信息System.Web.Services.Protocols.SoapE

linq分页问题
使用linq 分页是的时候当到第二页的时候就报错。错误信息
System.Web.Services.Protocols.SoapException: 服务器无法处理请求。 ---> System.NotSupportedException: 此提供程序只支持对返回实体或投影(包含所有标识列)的有序查询使用 Skip(),这种查询为单表(非联接)查询,或者为 Distinct、Except、Intersect 或 Union (非 Concat)操作。
  在 System.Data.Linq.SqlClient.SingleTableQueryVisitor.VisitSelect(SqlSelect select)
  在 System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node)
  在 System.Data.Linq.SqlClient.SingleTableQueryVisitor.Visit(SqlNode node)
  在 System.Data.Linq.SqlClient.SqlVisitor.VisitAlias(SqlAlias a)
  在 System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node)
  在 System.Data.Linq.SqlClient.SingleTableQueryVisitor.VisitSelect(SqlSelect select)
  在 System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node)
  在 System.Data.Linq.SqlClient.SingleTableQueryVisitor.Visit(SqlNode node)
  在 System.Data.Linq.SqlClient.SqlVisitor.VisitAlias(SqlAlias a)
  在 System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node)
  在 System.Data.Linq.SqlClient.SingleTableQueryVisitor.VisitSelect(SqlSelect select)
  在 System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node)
  在 System.Data.Linq.SqlClient.SingleTableQueryVisitor.Visit(SqlNode node)
  在 System.Data.Linq.SqlClient.SqlVisitor.VisitAlias(SqlAlias a)
  在 System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node)
  在 System.Data.Linq.SqlClient.SingleTableQueryVisitor.VisitSelect(SqlSelect select)
  在 System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node)
  在 System.Data.Linq.SqlClient.SingleTableQueryVisitor.Visit(SqlNode node)
  在 System.Data.Linq.SqlClient.QueryConverter.GenerateSkipTake(SqlSelect sequence, SqlExpression skipExp, SqlExpression takeExp)
  在 System.Data.Linq.SqlClient.QueryConverter.VisitTake(Expression sequence, Expression count)
  在 System.Data.Linq.SqlClient.QueryConverter.VisitSequenceOperatorCall(MethodCallExpression mc)
  在 System.Data.Linq.SqlClient.QueryConverter.VisitMethodCall(MethodCallExpression mc)
  在 System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node)
  在 System.Data.Linq.SqlClient.QueryConverter.ConvertOuter(Expression node)
  在 System.Data.Linq.SqlClient.SqlProvider.BuildQuery(Expression query, SqlNodeAnnotations annotations)
  在 System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
  在 System.Data.Linq.DataQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
  在 System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
  在 System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
  在 kltz.zxzd.insfyf.dal.NEWS_REFER_VIEWDAL.getnewsbycontation(Int32 pagesize, Int32 pageindex, Int32& totalcount) 位置 \\192.168.1.92\d$\infsysAspNet\kltz.zxzd.insfyf.dal\NEWS_REFER_VIEWDAL.cs:行号 21
  在 kltz.zxzd.insfyf.bll.NEWS_REFER_VIEWBLL.getnewsbycontation(Int32 pagesize, Int32 pageindex, Int32& totalcount) 位置 \\192.168.1.92\d$\infsysAspNet\kltz.zxzd.insfyf.bll\NEWS_REFER_VIEWBLL.cs:行号 17
  在 Service.HelloWorld(Int32 pagesize, Int32 pageindex, Int32& totalcount)
  --- 内部异常堆栈跟踪的结尾 --- 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 

我的源码: infsysdb.NEWS_REFER_VIEW.Where(p => p.SmallClassName == "政策内线").OrderByDescending(p => p.NewsID).Skip((pageindex - 1) * pagesize).Take(pagesize).ToList();


数据库使用的是sqlserver 2000 但是我在infsysDB.designer.cs 文件中将视图中做了主键设置
public partial class NEWS_PRESS_VIEW
{

private System.Nullable<System.Guid> _GUID;

private int _NEWSID;

private string _BIGCLASSNAME;

private string _SMALLCLASSNAME;

private string _TITLE;

private string _CORP;

private string _AUTHOR;


private string _STOCKCODE;

private string _ORIGINAL;

private System.Nullable<System.DateTime> _UPDATETIME;

private string _CONTENT;

private System.Nullable<int> _SPECIALID;

private System.Nullable<int> _HOT;

private System.Nullable<int> _CLICK;

private string _KEYWORD;

private System.Nullable<bool> _ISTOP;

private System.Nullable<bool> _ISELITE;

private string _MYGRADE;

private System.Nullable<bool> _ISFREE;

private string _REPORTTYPE;

private string _EDITOR;

private System.Nullable<bool> _ISFIRSTTOP;

private string _FROMNAME;

private string _ROLEID;

private string _MSN;

private System.Nullable<System.DateTime> _CREATETIME;

private string _SECTITLE;

private System.Nullable<bool> _ISTOPLINK;

private string _SSPELL;

private System.Nullable<bool> _ISCHECK;

private System.Nullable<int> _ISLOOK;

private System.Nullable<int> _ISVIP;

private string _EDITION;

private System.Nullable<int> _NEEDPOINT;

private System.Nullable<int> _SPECIALTYPE;

public NEWS_PRESS_VIEW()
{
}

[Column(Storage="_GUID", DbType="UniqueIdentifier")]
public System.Nullable<System.Guid> GUID
{
get
{
return this._GUID;
}
set
{
if ((this._GUID != value))
{
this._GUID = value;
}
}
}
  [Column(Storage = "_NEWSID", DbType = "Int NOT NULL", IsDbGenerated = true, IsPrimaryKey = true)]

  public int NEWSID
{
get
{
return this._NEWSID;
}
set
{
if ((this._NEWSID != value))
{
this._NEWSID = value;
}
}
}



[解决办法]
System.Web.Services.Protocols.SoapException: 服务器无法处理请求。 ---> System.NotSupportedException: 此提供程序只支持对返回实体或投影(包含所有标识列)的有序查询使用 Skip(),这种查询为单表(非联接)查询,或者为 Distinct、Except、Intersect 或 Union (非 Concat)操作。
[解决办法]
没有办法去详细分析。

给你个建议:退回去!

具体地说,不要使用存储过程,也不要使用视图,先把程序编正确。以后再考虑使用视图和存储过程的问题。
[解决办法]

热点排行