-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathICollection.cs
102 lines (89 loc) · 3.04 KB
/
ICollection.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace Citolab.Persistence
{
/// <summary>
/// Interface for retrieving data
/// </summary>
/// <typeparam name="T"></typeparam>
public interface ICollection<T> where T : Model, new()
{
/// <summary>
/// Get all objects, linq queries can be done on the IQueryable collection.
/// </summary>
/// <returns></returns>
IQueryable<T> AsQueryable();
/// <summary>
/// Get document.
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<T> GetAsync(Guid id);
/// <summary>
/// Gets one or more documents identified by the supplied ids.
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
Task<IEnumerable<T>> GetAsync(params Guid[] ids);
/// <summary>
/// Update a document.
/// </summary>
/// <param name="document"></param>
/// <returns></returns>
Task<bool> UpdateAsync(T document);
/// <summary>
/// Add document.
/// </summary>
/// <param name="document"></param>
/// <returns></returns>
Task<T> AddAsync(T document);
/// <summary>
/// Add multiple documents
/// </summary>
/// <param name="documents"></param>
/// <returns></returns>
Task AddManyAsync(IList<T> documents);
/// <summary>
/// Delete document.
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<bool> DeleteAsync(Guid id);
/// <summary>
/// Gets the number of documents in the collection
/// </summary>
/// <returns></returns>
Task<long> GetCountAsync();
/// <summary>
/// Gets the number of documents in the collection that satisfy the filter.
/// </summary>
/// <param name="filter"></param>
/// <returns></returns>
Task<long> GetCountAsync(Expression<Func<T, bool>> filter);
/// <summary>
/// True if the collection contains documents.
/// </summary>
/// <returns></returns>
Task<bool> AnyAsync();
/// <summary>
/// True if the collection contains documents that satisfy the filter.
/// </summary>
/// <param name="filter"></param>
/// <returns></returns>
Task<bool> AnyAsync(Expression<Func<T, bool>> filter);
/// <summary>
/// Get the first or default in the collection.
/// </summary>
/// <returns></returns>
Task<T> FirstOrDefaultAsync();
/// <summary>
/// Get the first or default in the collection that satisfies the filter.
/// </summary>
/// <param name="filter"></param>
/// <returns></returns>
Task<T> FirstOrDefaultAsync(Expression<Func<T, bool>> filter);
}
}