Skip to content

Commit

Permalink
fix(MultiDocumentQueryExtensions): add missing ToListAsync overload
Browse files Browse the repository at this point in the history
  • Loading branch information
seangwright committed Jan 2, 2022
1 parent cd0ddf5 commit f1f32a1
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ public static async Task<IList<TreeNode>> ToListAsync(this MultiDocumentQuery qu
return result.ToList();
}

/// <summary>
/// Converts the <paramref name="query"/> to a <see cref="List{T}"/> of <see cref="TreeNode"/>
/// </summary>
/// <param name="query">The current MultiDocumentQuery</param>
/// <param name="projection">Mapping function from <see cref="TreeNode"/> to <typeparamref name="TReturn" /></param>
/// <param name="token">Optional cancellation token</param>
/// <returns></returns>
public static async Task<IList<TReturn>> ToListAsync<TReturn>(
this MultiDocumentQuery query,
Func<TreeNode, TReturn> projection,
CancellationToken token = default)
{
var result = await query.GetEnumerableTypedResultAsync(cancellationToken: token);

return result.Select(projection).ToList();
}

/// <summary>
/// Returns the first item of the <paramref name="query"/> as the generic Page type and null if no items were returned.
/// </summary>
Expand Down

0 comments on commit f1f32a1

Please sign in to comment.