[英]How to do pagination in couchdb using loveseat in c#
我需要在应用程序中向下滚动页面加载。 我正在使用ouchdb作为后端,并且在couchdb中找到了一个分页选项,我认为这可以满足我的问题。
问题是我在任何地方都找不到分页的有效示例。 我需要有人的帮助才能使我的应用程序与此版本一起使用。
请看一下以供参考: https : //github.com/soitgoes/LoveSeat/blob/master/LoveSeat/PagingHelper.cs
这是我的代码。 我在options = model.GetOptions();
遇到错误options = model.GetOptions();
行,说“对象引用未设置为对象的实例”。
public List<newVO> Getdocs(IPageableModel model)
{
List<newVO> resultList = new List<newVO>();
var etag = "";
ViewOptions options = new ViewOptions();
options = model.GetOptions();
options.StartKeyDocId = lastId;
options.Limit = 13;
options.Skip = 1;
var result = oCouchDB.View<newVO>("GetAlldocs", options);
//model.UpdatePaging(options, result);
if (result.StatusCode == HttpStatusCode.NotModified)
{
response.StatusCode = "0";
return null;
}
if (result != null)
{
foreach (newVO newvo in result.Items)
{
resultList.Add(newvo );
}
}
return resultList;
}
提前致谢。 欢迎所有想法。
public List<newVO> Getdocs(IPageableModel model)
{
List<newVO> resultList = new List<newVO>();
var etag = "";
ViewOptions options = new ViewOptions();
options = model.GetOptions();
options.StartKeyDocId = lastId;
options.Limit = 13;
options.Skip = 1;
var result = oCouchDB.View<newVO>("GetAlldocs", options);
//model.UpdatePaging(options, result);
if (result.StatusCode == HttpStatusCode.NotModified)
{
response.StatusCode = "0";
return null;
}
if (result != null)
{
foreach (newVO newvo in result.Items)
{
resultList.Add(newvo );
}
}
return resultList;
}
这是我的代码,并且在“ options = model.GetOptions();”中出现错误 该对象引用未设置为对象实例的行...
我没有使用LoveSeat分页实现,但是可以使用ViewOptions
的Limit
和Skip
属性来实现分页:
public static IEnumerable<T> GetPage(this ICouchDatabase couchDatabase,
string viewName,
string designDoc,
int page,
int pageSize)
{
return couchDatabase.View(viewName, new ViewOptions
{
Skip = page * pageSize,
Limit = pageSize
}, designDoc);
}
这种简单的扩展方法将从CouchDB视图获取数据页面
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.