forked from MicrosoftDocs/mslearn-tailspin-spacegame-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IDocumentDBRepository.cs
executable file
·50 lines (47 loc) · 2.15 KB
/
IDocumentDBRepository.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
using TailSpin.SpaceGame.Web.Models;
namespace TailSpin.SpaceGame.Web
{
public interface IDocumentDBRepository<T> where T : Model
{
/// <summary>
/// Retrieves the item from the store with the given identifier.
/// </summary>
/// <returns>
/// A task that represents the asynchronous operation.
/// The task result contains the retrieved item.
/// </returns>
/// <param name="id">The identifier of the item to retrieve.</param>
Task<T> GetItemAsync(string id);
/// <summary>
/// Retrieves items from the store that match the given query predicate.
/// Results are given in descending order by the given ordering predicate.
/// </summary>
/// <returns>
/// A task that represents the asynchronous operation.
/// The task result contains the collection of retrieved items.
/// </returns>
/// <param name="queryPredicate">Predicate that specifies which items to select.</param>
/// <param name="orderDescendingPredicate">Predicate that specifies how to sort the results in descending order.</param>
/// <param name="page">The 1-based page of results to return.</param>
/// <param name="pageSize">The number of items on a page.</param>
Task<IEnumerable<T>> GetItemsAsync(
Expression<Func<T, bool>> queryPredicate,
Expression<Func<T, int>> orderDescendingPredicate,
int page = 1,
int pageSize = 10
);
/// <summary>
/// Retrieves the number of items that match the given query predicate.
/// </summary>
/// <returns>
/// A task that represents the asynchronous operation.
/// The task result contains the number of items that match the query predicate.
/// </returns>
/// <param name="queryPredicate">Predicate that specifies which items to select.</param>
Task<int> CountItemsAsync(Expression<Func<T, bool>> queryPredicate);
}
}