本文整理汇总了C#中PagedList.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# PagedList.AddRange方法的具体用法?C# PagedList.AddRange怎么用?C# PagedList.AddRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PagedList
的用法示例。
在下文中一共展示了PagedList.AddRange方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindAllAsync
public async static Task<PagedList<Connection>> FindAllAsync(string type, string query = null, IEnumerable<string> fields = null, int page = 1, int pageSize = 20, string orderBy = null, SortOrder sortOrder = SortOrder.Descending)
{
var request = new FindAllConnectionsRequest()
{
Type = type,
Query = query,
PageNumber = page,
PageSize = pageSize,
OrderBy = orderBy,
SortOrder = sortOrder
};
var response = await request.ExecuteAsync();
if (response.Status.IsSuccessful == false)
throw response.Status.ToFault();
var connections = new PagedList<Connection>()
{
PageNumber = response.PagingInfo.PageNumber,
PageSize = response.PagingInfo.PageSize,
TotalRecords = response.PagingInfo.TotalRecords,
GetNextPage = async skip => await FindAllAsync(type, query, fields, page + skip + 1, pageSize)
};
connections.AddRange(response.Connections);
return connections;
}
示例2: FindAllAsync
public async static Task<PagedList<Article>> FindAllAsync(string type, string query = null, IEnumerable<string> fields = null, int page = 1, int pageSize = 20, string orderBy = null, SortOrder sortOrder = SortOrder.Descending )
{
var service = ObjectFactory.Build<IArticleService>();
var request = new FindAllArticleRequest()
{
Type = type,
Query = query,
PageNumber = page,
PageSize = pageSize,
OrderBy = orderBy,
SortOrder = sortOrder
};
var response = await service.FindAllAsync(request);
if (response.Status.IsSuccessful == false)
throw response.Status.ToFault();
var articles = new PagedList<Article>()
{
PageNumber = response.PagingInfo.PageNumber,
PageSize = response.PagingInfo.PageSize,
TotalRecords = response.PagingInfo.TotalRecords,
GetNextPage = async skip => await FindAllAsync(type, query, fields, page+skip+1, pageSize)
};
articles.AddRange(response.Articles);
return articles;
}
示例3: FindAllAsync
/// <summary>
/// Finds a paginated list of APDevices for the given type and search criteria.
/// </summary>
/// <param name="freeTextExpression">Free text search expression over all fields of the given type.</param>
/// <param name="query">The search query</param>
/// <param name="fields">The device specific fields to be retrieved.</param>
/// <param name="pageNumber">The page number.</param>
/// <param name="pageSize">The page size.</param>
/// <param name="orderBy">The field on which to sort.</param>
/// <param name="sortOrder">Sort order - Ascending or Descending.</param>
/// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
/// <returns>A paginated list of APDevice objects for the given search criteria.</returns>
public async static Task<PagedList<APDevice>> FindAllAsync(string freeTextExpression, IQuery query = null, IEnumerable<string> fields = null, int pageNumber = 1, int pageSize = 20, string orderBy = null, SortOrder sortOrder = SortOrder.Descending, ApiOptions options = null)
{
var objects = await APObjects.FindAllAsync("device", freeTextExpression, query, fields, pageNumber, pageSize, orderBy, sortOrder, options);
var devices = objects.Select(x => x as APDevice);
var list = new PagedList<APDevice>()
{
PageNumber = objects.PageNumber,
PageSize = objects.PageSize,
TotalRecords = objects.TotalRecords,
GetNextPage = async skip => await FindAllAsync(freeTextExpression, query, fields, pageNumber + skip + 1, pageSize, orderBy, sortOrder, options)
};
list.AddRange(devices);
return list;
}
示例4: FindAllAsync
public async static Task<PagedList<Device>> FindAllAsync(string query = null, IEnumerable<string> fields = null, int page = 1, int pageSize = 20, string orderBy = null, SortOrder sortOrder = SortOrder.Descending)
{
var articles = await Articles.FindAllAsync("device", query, fields, page, pageSize, orderBy, sortOrder);
var devices = articles.Select(x => new Device(x));
var list = new PagedList<Device>()
{
PageNumber = articles.PageNumber,
PageSize = articles.PageSize,
TotalRecords = articles.TotalRecords,
GetNextPage = async skip => await FindAllAsync(query, fields, page + skip + 1, pageSize, orderBy, sortOrder)
};
list.AddRange(devices);
return list;
}
示例5: GetListItemsAsync
public static async Task<PagedList<ListItem>> GetListItemsAsync(string listName, int page = 1, int pageSize = 20)
{
var request = new GetListContentRequest
{
Name = listName,
PageNumber = page,
PageSize = pageSize
};
var response = await request.ExecuteAsync();
if (response.Status.IsSuccessful == false)
throw response.Status.ToFault();
var list = new PagedList<ListItem>()
{
PageNumber = response.PagingInfo.PageNumber,
PageSize = response.PagingInfo.PageSize,
TotalRecords = response.PagingInfo.TotalRecords,
GetNextPage = async skip => await GetListItemsAsync(listName, pageSize, page + skip + 1)
};
list.AddRange(response.Items);
return list;
}
示例6: GetConnectionsAsync
/// <summary>
/// Gets a paginated list of APConnections for the current object of the given connection type.
/// </summary>
/// <param name="connectionType">The type (relation name) of the connection.</param>
/// <param name="query">Search query to further filter the list of connection objects.</param>
/// <param name="label">Label of the endpoint to be queried. This is mandatory when the connection type being queried has endpoints with the same type but different labels.</param>
/// <param name="fields">The fields to be returned for the matching objects.</param>
/// <param name="pageNumber">The page number.</param>
/// <param name="pageSize">The page size.</param>
/// <param name="orderBy">The field on which to sort the results.</param>
/// <param name="sortOrder">The sort order - Ascending or Descending.</param>
/// <returns>A paginated list of APConnection objects.</returns>
public async Task<PagedList<APConnection>> GetConnectionsAsync(string connectionType, string query = null, string label = null, IEnumerable<string> fields = null, int pageNumber = 1, int pageSize = 20, string orderBy = null, SortOrder sortOrder = SortOrder.Descending, ApiOptions options = null)
{
var request = new FindConnectedObjectsRequest
{
Relation = connectionType,
ObjectId = this.Id,
Object = this,
Query = query,
Label = label,
Type = this.Type,
ReturnEdge = true,
PageNumber = pageNumber,
PageSize = pageSize,
SortOrder = sortOrder,
OrderBy = orderBy
};
if (fields != null)
request.Fields.AddRange(fields);
ApiOptions.Apply(request, options);
var response = await request.ExecuteAsync();
if (response.Status.IsSuccessful == false)
throw response.Status.ToFault();
var list = new PagedList<APConnection>
{
PageNumber = response.PagingInfo.PageNumber,
PageSize = response.PagingInfo.PageSize,
TotalRecords = response.PagingInfo.TotalRecords,
GetNextPage = async skip => await GetConnectionsAsync(connectionType, query, null, fields, pageNumber + skip + 1, pageSize, orderBy, sortOrder, options)
};
list.AddRange(response.Nodes.Select(n => n.Connection));
return list;
}
示例7: FindAllAsync
/// <summary>
/// Finds a paginated list of APConnections for the given type and search criteria.
/// </summary>
/// <param name="type">The type (relation name) of the connection.</param>
/// <param name="freeTextExpression">Free text search expression over all fields of the given type.</param>
/// <param name="query">The search query</param>
/// <param name="fields">The specific fields of the conection to be retrieved.</param>
/// <param name="pageNumber">The page number.</param>
/// <param name="pageSize">The page size.</param>
/// <param name="orderBy">The field on which to sort.</param>
/// <param name="sortOrder">Sort order - Ascending or Descending.</param>
/// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
/// <returns>A paginated list of APConnections for the given search criteria.</returns>
public async static Task<PagedList<APConnection>> FindAllAsync(string type, string freeTextExpression, IQuery query = null, IEnumerable<string> fields = null, int pageNumber = 1, int pageSize = 20, string orderBy = null, SortOrder sortOrder = SortOrder.Descending, ApiOptions options = null)
{
query = query ?? Query.None;
var request = new FindAllConnectionsRequest()
{
Type = type,
FreeTextExpression = freeTextExpression,
Query = query.AsString().Escape(),
PageNumber = pageNumber,
PageSize = pageSize,
OrderBy = orderBy,
SortOrder = sortOrder
};
ApiOptions.Apply(request, options);
var response = await request.ExecuteAsync();
if (response.Status.IsSuccessful == false)
throw response.Status.ToFault();
var connections = new PagedList<APConnection>()
{
PageNumber = response.PagingInfo.PageNumber,
PageSize = response.PagingInfo.PageSize,
TotalRecords = response.PagingInfo.TotalRecords,
GetNextPage = async skip => await FindAllAsync(type, freeTextExpression, query, fields, pageNumber + skip + 1, pageSize, orderBy, sortOrder, options)
};
connections.AddRange(response.Connections);
return connections;
}
示例8: GetConnectionsAsync
public async static Task<PagedList<Connection>> GetConnectionsAsync(string relation, string articleId, string query = null, IEnumerable<string> fields = null, int pageNumber = 1, int pageSize = 20)
{
IConnectionService connService = ObjectFactory.Build<IConnectionService>();
var request = new FindConnectedArticlesRequest
{
Relation = relation,
ArticleId = articleId,
Query = query,
PageNumber = pageNumber,
PageSize = pageSize
};
if (fields != null)
request.Fields.AddRange(fields);
var response = await connService.FindConnectedArticlesAsync(request);
if (response.Status.IsSuccessful == false)
throw response.Status.ToFault();
var list = new PagedList<Connection>
{
PageNumber = response.PagingInfo.PageNumber,
PageSize = response.PagingInfo.PageSize,
TotalRecords = response.PagingInfo.TotalRecords,
GetNextPage = async skip => await GetConnectionsAsync(relation, articleId, query, fields, pageNumber + skip + 1, pageSize)
};
list.AddRange(response.Connections);
return list;
}
示例9: FreeTextSearchAsync
/// <summary>
/// Gets a paginated list of APObjects matching the given freetext search expression.
/// The provided expression is matched with the entire object instead of a particular field.
/// </summary>
/// <param name="type">The object type</param>
/// <param name="freeTextExpression">Freetext expression.</param>
/// <param name="fields">The specific object fields to be retrieved. </param>
/// <param name="pageNumber">The page number.</param>
/// <param name="pageSize">The page size.</param>
/// <param name="orderBy">The object field on which the results should be sorted.</param>
/// <param name="sortOrder">The sort order.</param>
/// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
/// <returns>Paginated list of APObject objects matching the given search criteria.</returns>
public async static Task<PagedList<APObject>> FreeTextSearchAsync(string type, string freeTextExpression, IEnumerable<string> fields = null, int pageNumber = 1, int pageSize = 20, string orderBy = null, SortOrder sortOrder = SortOrder.Descending, ApiOptions options = null)
{
var request = new FreeTextSearchObjectsRequest()
{
Type = type,
FreeTextExpression = freeTextExpression,
PageNumber = pageNumber,
PageSize = pageSize,
OrderBy = orderBy,
SortOrder = sortOrder
};
if (fields != null)
request.Fields.AddRange(fields);
ApiOptions.Apply(request, options);
var response = await request.ExecuteAsync();
if (response.Status.IsSuccessful == false)
throw response.Status.ToFault();
var objects = new PagedList<APObject>()
{
PageNumber = response.PagingInfo.PageNumber,
PageSize = response.PagingInfo.PageSize,
TotalRecords = response.PagingInfo.TotalRecords,
GetNextPage = async skip => await FreeTextSearchAsync(type, freeTextExpression, fields, pageNumber + skip + 1, pageSize, orderBy, sortOrder, options)
};
objects.AddRange(response.Objects);
return objects;
}
示例10: GetBlogPosts
public PagedList<Post> GetBlogPosts(int pageNumber, int pageSize, PostsSortEnum sort = PostsSortEnum.Newest, Tag tag = null, Category category = null)
{
var queryActions = new List<Action<IQuery>>();
// base where query
var where = "where VersionOf.ID Is Null and ( ci.class = :class And ci.Parent.ID = :parentId)";
queryActions.Add(q =>
{
q.SetCacheable(true);
q.SetParameter("class", "Post");
q.SetParameter("parentId", ID);
});
// are we filtering by a tag?
if (tag != null)
{
where += " and (ci in (select cd.EnclosingItem from ContentDetail cd where cd.LinkedItem in (:tagItem) AND cd.Name = :tagDetailName))";
queryActions.Add(q =>
{
q.SetParameter("tagItem", tag);
q.SetParameter("tagDetailName", "BlogTags");
});
}
// are we filtering by a category?
if (category != null)
{
where += " and (ci in (select cd.EnclosingItem from ContentDetail cd where cd.LinkedItem in (:categoryItem) AND cd.Name = :categoryDetailName))";
queryActions.Add(q =>
{
q.SetParameter("categoryItem", category);
q.SetParameter("categoryDetailName", "BlogCategories");
});
}
// get the posts paged
var query = Context.Current.Resolve<ISessionProvider>().OpenSession.Session.CreateQuery("select ci from ContentItem ci " + where + " order by (select MAX(DateTimeValue) from ContentDetail cd where cd.EnclosingItem = ci and cd.Name = 'postCreatedDate') desc");
query.SetFirstResult((pageNumber - 1) * pageSize);
query.SetMaxResults(pageSize);
Array.ForEach(queryActions.ToArray(), a => a(query));
var posts = query.List<Post>();
// get the total number of posts
query = Context.Current.Resolve<ISessionProvider>().OpenSession.Session.CreateQuery("select count(*) from ContentItem ci " + where);
Array.ForEach(queryActions.ToArray(), a => a(query));
var total = Convert.ToInt32(query.List()[0]);
// return the paged list
var pagedList = new PagedList<Post>();
pagedList.AddRange(posts);
pagedList.PageNumber = pageNumber;
pagedList.PageSize = pageSize;
pagedList.TotalCount = total;
pagedList.TotalPages = (int)Math.Ceiling((decimal)total / pageSize);
return pagedList;
}
示例11: FindAllAsync
/// <summary>
/// Gets a paged list of all matching users.
/// </summary>
/// <param name="query">Filter query to filter out a specific list of users. </param>
/// <param name="fields">List of fields to return</param>
/// <param name="pageNumber">Page number</param>
/// <param name="pageSize">Page size</param>
/// <param name="orderBy">The field on which to sort.</param>
/// <param name="sortOrder">Sort order - Ascending or Descending.</param>
/// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
/// <returns>A paged list of users.</returns>
public async static Task<PagedList<APUser>> FindAllAsync(IQuery query = null, IEnumerable<string> fields = null, int pageNumber = 1, int pageSize = 20, string orderBy = null, SortOrder sortOrder = SortOrder.Descending, ApiOptions options = null)
{
query = query ?? Query.None;
var request = new FindAllUsersRequest()
{
Query = query.AsString().Escape(),
PageNumber = pageNumber,
PageSize = pageSize,
OrderBy = orderBy,
SortOrder = sortOrder
};
if (fields != null)
request.Fields.AddRange(fields);
ApiOptions.Apply(request, options);
var response = await request.ExecuteAsync();
if (response.Status.IsSuccessful == false)
throw response.Status.ToFault();
var users = new PagedList<APUser>()
{
PageNumber = response.PagingInfo.PageNumber,
PageSize = response.PagingInfo.PageSize,
TotalRecords = response.PagingInfo.TotalRecords,
GetNextPage = async skip => await FindAllAsync(query, fields, pageNumber + skip + 1, pageSize, orderBy, sortOrder, options)
};
users.AddRange(response.Users);
return users;
}
示例12: FindAllAsync
/// <summary>
/// Gets a paged list of all matching users.
/// </summary>
/// <param name="query">Filter query to filter out a specific list of users. </param>
/// <param name="fields">List of fields to return</param>
/// <param name="page">Page number</param>
/// <param name="pageSize">Page size</param>
/// <returns>A paged list of users.</returns>
public async static Task<PagedList<User>> FindAllAsync(string query = null, IEnumerable<string> fields = null, int page = 1, int pageSize = 20, string orderBy = null, SortOrder sortOrder = SortOrder.Descending)
{
var request = new FindAllUsersRequest()
{
Query = query,
PageNumber = page,
PageSize = pageSize,
OrderBy = orderBy,
SortOrder = sortOrder
};
if (fields != null)
request.Fields.AddRange(fields);
var response = await request.ExecuteAsync();
if (response.Status.IsSuccessful == false)
throw response.Status.ToFault();
var users = new PagedList<User>()
{
PageNumber = response.PagingInfo.PageNumber,
PageSize = response.PagingInfo.PageSize,
TotalRecords = response.PagingInfo.TotalRecords,
GetNextPage = async skip => await FindAllAsync(query, fields, page + skip + 1, pageSize)
};
users.AddRange(response.Articles);
return users;
}
示例13: GetConnectedArticlesAsync
public async static Task<PagedList<Article>> GetConnectedArticlesAsync(string relation, string articleId, string query = null, string label = null, IEnumerable<string> fields = null, int pageNumber = 1, int pageSize = 20)
{
var request = new FindConnectedArticlesRequest
{
Relation = relation,
ArticleId = articleId,
Label = label,
Query = query,
PageNumber = pageNumber,
PageSize = pageSize
};
if (fields != null)
request.Fields.AddRange(fields);
var response = await request.ExecuteAsync();
if (response.Status.IsSuccessful == false)
throw response.Status.ToFault();
IEnumerable<Article> articles = null;
// if label is specified, then get the labelled endpoint
if (string.IsNullOrWhiteSpace(label) == false)
articles = response.Connections.Select(c => c.Endpoints[label].Content);
else
articles = response.Connections.Select(c =>
{
if (c.Endpoints.EndpointA.ArticleId == articleId)
return c.Endpoints.EndpointB.Content;
else
return c.Endpoints.EndpointA.Content;
});
var list = new PagedList<Article>()
{
PageNumber = response.PagingInfo.PageNumber,
PageSize = response.PagingInfo.PageSize,
TotalRecords = response.PagingInfo.TotalRecords,
GetNextPage = async skip => await GetConnectedArticlesAsync(relation, articleId, query, label, fields, pageNumber + skip + 1, pageSize)
};
list.AddRange(articles);
return list;
}