本文整理汇总了C#中IQuery.AsString方法的典型用法代码示例。如果您正苦于以下问题:C# IQuery.AsString方法的具体用法?C# IQuery.AsString怎么用?C# IQuery.AsString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IQuery
的用法示例。
在下文中一共展示了IQuery.AsString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindAllAsync
/// <summary>
/// Gets a paginated list of APObjects matching the given search criteria.
/// </summary>
/// <param name="type">The object type.</param>
/// <param name="query">The search query for objects to be found.</param>
/// <param name="fields">The object fields to be returned for the matching list of objects.</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>> FindAllAsync(string type, 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 FindAllObjectsRequest()
{
Type = type,
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 objects = new PagedList<APObject>()
{
PageNumber = response.PagingInfo.PageNumber,
PageSize = response.PagingInfo.PageSize,
TotalRecords = response.PagingInfo.TotalRecords,
GetNextPage = async skip => await FindAllAsync(type, query, fields, pageNumber + skip + 1, pageSize, orderBy, sortOrder, options)
};
objects.AddRange(response.Objects);
return objects;
}
示例2: GetConnectionsAsync
/// <summary>
/// Gets a paginated list of APConnections for the given object of the given connection type.
/// </summary>
/// <param name="objectId">The object id to be queried.</param>
/// <param name="type">The object type (schema name).</param>
/// <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>
/// <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 APConnection objects.</returns>
public async static Task<PagedList<APConnection>> GetConnectionsAsync(string relation, string schemaType, string objectId, IQuery query = null, string label = null, IEnumerable<string> fields = null, int pageNumber = 1, int pageSize = 20, string orderBy = null, SortOrder sortOrder = SortOrder.Ascending, ApiOptions options = null)
{
query = query ?? Query.None;
return await new APObject(schemaType, objectId).GetConnectionsAsync(relation, query.AsString(), label, fields, pageNumber, pageSize, orderBy, sortOrder, options);
}