This repository has been archived by the owner on Feb 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 298
/
IMobileServiceTable.Generic.cs
377 lines (347 loc) · 14.8 KB
/
IMobileServiceTable.Generic.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
// ----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// ----------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace Microsoft.WindowsAzure.MobileServices
{
/// <summary>
/// Provides operations on a table for a Mobile Service.
/// </summary>
/// <typeparam name="T">
/// The type of instances in the table (which implies the table).
/// </typeparam>
public interface IMobileServiceTable<T> : IMobileServiceTable
{
/// <summary>
/// Executes a query against the table.
/// </summary>
/// <param name="query">
/// A query to execute.
/// </param>
/// <returns>
/// A task that will return with results when the query finishes.
/// </returns>
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "Generic are not nested when used via async.")]
Task<IEnumerable<U>> ReadAsync<U>(string query);
/// <summary>
/// Returns instances from a table using a query.
/// </summary>
/// <typeparam name="U">
/// The type of instance returned by the query.
/// </typeparam>
/// <param name="query">
/// The query to execute.
/// </param>
/// <returns>
/// Instances from the table.
/// </returns>
[SuppressMessage("Microsoft.Naming", "CA1715:IdentifiersShouldHaveCorrectPrefix", MessageId = "T", Justification = "Part of the LINQ query pattern")]
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "U", Justification = "Part of the LINQ query pattern")]
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "Generic are not nested when used via async.")]
Task<IEnumerable<U>> ReadAsync<U>(IMobileServiceTableQuery<U> query);
/// <summary>
/// Returns instances from a table.
/// </summary>
/// <returns>
/// Instances from the table.
/// </returns>
/// <remarks>
/// This call will not handle paging, etc., for you.
/// </remarks>
Task<IEnumerable<T>> ReadAsync();
/// <summary>
/// Lookup an instance from a table by its id.
/// </summary>
/// <param name="id">
/// The id of the instance.
/// </param>
/// <returns>
/// The desired instance.
/// </returns>
new Task<T> LookupAsync(object id);
/// <summary>
/// Lookup an instance from a table by its id.
/// </summary>
/// <param name="id">
/// The id of the instance.
/// </param>
/// <param name="parameters">
/// A dictionary of user-defined parameters and values to include in
/// the request URI query string.
/// </param>
/// <returns>
/// The desired instance.
/// </returns>
new Task<T> LookupAsync(object id, IDictionary<string, string> parameters);
/// <summary>
/// Refresh the current instance with the latest values from the
/// table.
/// </summary>
/// <param name="instance">
/// The instance to refresh.
/// </param>
/// <returns>
/// A task that will complete when the refresh has finished.
/// </returns>
Task RefreshAsync(T instance);
/// <summary>
/// Refresh the current instance with the latest values from the
/// table.
/// </summary>
/// <param name="instance">
/// The instance to refresh.
/// </param>
/// <param name="parameters">
/// A dictionary of user-defined parameters and values to include in
/// the request URI query string.
/// </param>
/// <returns>
/// A task that will complete when the refresh has finished.
/// </returns>
Task RefreshAsync(T instance, IDictionary<string, string> parameters);
/// <summary>
/// Insert a new instance into the table.
/// </summary>
/// <param name="instance">
/// The instance to insert.
/// </param>
/// <returns>
/// A task that will complete when the insertion has finished.
/// </returns>
Task InsertAsync(T instance);
/// <summary>
/// Insert a new instance into the table.
/// </summary>
/// <param name="instance">
/// The instance to insert.
/// </param>
/// <param name="parameters">
/// A dictionary of user-defined parameters and values to include in
/// the request URI query string.
/// </param>
/// <returns>
/// A task that will complete when the insertion has finished.
/// </returns>
Task InsertAsync(T instance, IDictionary<string, string> parameters);
/// <summary>
/// Updates an instance in the table.
/// </summary>
/// <param name="instance">
/// The instance to update.
/// </param>
/// <returns>
/// A task that will complete when the update has finished.
/// </returns>
Task UpdateAsync(T instance);
/// <summary>
/// Updates an instance in the table.
/// </summary>
/// <param name="instance">
/// The instance to update.
/// </param>
/// <param name="parameters">
/// A dictionary of user-defined parameters and values to include in
/// the request URI query string.
/// </param>
/// <returns>
/// A task that will complete when the update has finished.
/// </returns>
Task UpdateAsync(T instance, IDictionary<string, string> parameters);
/// <summary>
/// Undeletes an <paramref name="instance"/> from the table. This requires the soft delete feature to be enabled on the Mobile Service. Visit <see href="http://go.microsoft.com/fwlink/?LinkId=507647">the link</see> for details.
/// </summary>
/// <param name="instance">The instance to undelete from the table.</param>
/// <returns>A task that will complete when the undelete finishes.</returns>
Task UndeleteAsync(T instance);
/// <summary>
/// Undeletes an <paramref name="instance"/> from the table. This requires the soft delete feature to be enabled on the Mobile Service. Visit <see href="http://go.microsoft.com/fwlink/?LinkId=507647">the link</see> for details.
/// </summary>
/// <param name="instance">The instance to undelete from the table.</param>
/// <param name="parameters">
/// A dictionary of user-defined parameters and values to include in
/// the request URI query string.
/// </param>
/// <returns>A task that will complete when the undelete finishes.</returns>
Task UndeleteAsync(T instance, IDictionary<string, string> parameters);
/// <summary>
/// Delete an instance from the table.
/// </summary>
/// <param name="instance">
/// The instance to delete.
/// </param>
/// <returns>
/// A task that will complete when the delete has finished.
/// </returns>
Task DeleteAsync(T instance);
/// <summary>
/// Delete an instance from the table.
/// </summary>
/// <param name="instance">The instance to delete.
/// </param>
/// <param name="parameters">
/// A dictionary of user-defined parameters and values to include in
/// the request URI query string.
/// </param>
/// <returns>
/// A task that will complete when the delete has finished.
/// </returns>
Task DeleteAsync(T instance, IDictionary<string, string> parameters);
/// <summary>
/// Creates a query for the current table.
/// </summary>
/// <returns>
/// A query against the table.
/// </returns>
IMobileServiceTableQuery<T> CreateQuery();
/// <summary>
/// Creates a query that will ensure it gets the total count for all
/// the records that would have been returned ignoring any take paging/
/// limit clause specified by client or server.
/// </summary>
/// <returns>
/// A query against the table.
/// </returns>
IMobileServiceTableQuery<T> IncludeTotalCount();
/// <summary>
/// Creates a query that will ensure it gets the deleted records. This requires the soft delete feature to be enabled on the Mobile Service. Visit <see href="http://go.microsoft.com/fwlink/?LinkId=507647">the link</see> for details.
/// </summary>
/// <returns>
/// A query against the table.
/// </returns>
IMobileServiceTableQuery<T> IncludeDeleted();
/// <summary>
/// Applies to the source query the specified string key-value
/// pairs to be used as user-defined parameters with the request URI
/// query string.
/// </summary>
/// <param name="parameters">
/// The parameters to apply.
/// </param>
/// <returns>
/// The composed query.
/// </returns>
IMobileServiceTableQuery<T> WithParameters(IDictionary<string, string> parameters);
/// <summary>
/// Creates a query by applying the specified filter predicate.
/// </summary>
/// <param name="predicate">
/// The filter predicate.
/// </param>
/// <returns>
/// A query against the table.
/// </returns>
IMobileServiceTableQuery<T> Where(Expression<Func<T, bool>> predicate);
/// <summary>
/// Creates a query by applying the specified selection.
/// </summary>
/// <typeparam name="U">
/// Type representing the projected result of the query.
/// </typeparam>
/// <param name="selector">
/// The selector function.
/// </param>
/// <returns>
/// A query against the table.
/// </returns>
[SuppressMessage("Microsoft.Naming", "CA1715:IdentifiersShouldHaveCorrectPrefix", MessageId = "T", Justification = "Standard for LINQ")]
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Select", Justification = "Part of the LINQ query pattern.")]
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "U", Justification = "Standard for LINQ")]
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "Part of the LINQ query pattern.")]
IMobileServiceTableQuery<U> Select<U>(Expression<Func<T, U>> selector);
/// <summary>
/// Creates a query by applying the specified ascending order clause.
/// </summary>
/// <typeparam name="TKey">
/// The type of the member being ordered by.
/// </typeparam>
/// <param name="keySelector">
/// The expression selecting the member to order by.
/// </param>
/// <returns>
/// A query against the table.
/// </returns>
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "Part of the LINQ query pattern.")]
IMobileServiceTableQuery<T> OrderBy<TKey>(Expression<Func<T, TKey>> keySelector);
/// <summary>
/// Creates a query by applying the specified descending order clause.
/// </summary>
/// <typeparam name="TKey">
/// The type of the member being ordered by.
/// </typeparam>
/// <param name="keySelector">
/// The expression selecting the member to order by.
/// </param>
/// <returns>
/// A query against the table.
/// </returns>
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "Part of the LINQ query pattern.")]
IMobileServiceTableQuery<T> OrderByDescending<TKey>(Expression<Func<T, TKey>> keySelector);
/// <summary>
/// Creates a query by applying the specified ascending order clause.
/// </summary>
/// <typeparam name="TKey">
/// The type of the member being ordered by.
/// </typeparam>
/// <param name="keySelector">
/// The expression selecting the member to order by.
/// </param>
/// <returns>
/// A query against the table.
/// </returns>
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "Part of the LINQ query pattern.")]
IMobileServiceTableQuery<T> ThenBy<TKey>(Expression<Func<T, TKey>> keySelector);
/// <summary>
/// Creates a query by applying the specified descending order clause.
/// </summary>
/// <typeparam name="TKey">
/// The type of the member being ordered by.
/// </typeparam>
/// <param name="keySelector">
/// The expression selecting the member to order by.
/// </param>
/// <returns>
/// A query against the table.
/// </returns>
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "Part of the LINQ query pattern.")]
IMobileServiceTableQuery<T> ThenByDescending<TKey>(Expression<Func<T, TKey>> keySelector);
/// <summary>
/// Creates a query by applying the specified skip clause.
/// </summary>
/// <param name="count">
/// The number to skip.
/// </param>
/// <returns>
/// A query against the table.
/// </returns>
IMobileServiceTableQuery<T> Skip(int count);
/// <summary>
/// Creates a query by applying the specified take clause.
/// </summary>
/// <param name="count">
/// The number to take.
/// </param>
/// <returns>
/// A query against the table.
/// </returns>
IMobileServiceTableQuery<T> Take(int count);
/// <summary>
/// Gets the elements of the table asynchronously.
/// </summary>
/// <returns>
/// The table elements results as a sequence.
/// </returns>
Task<IEnumerable<T>> ToEnumerableAsync();
/// <summary>
/// Gets the elements of the table asynchronously and return the
/// results in a new List.
/// </summary>
/// <returns>
/// The table elements results as a List.
/// </returns>
Task<List<T>> ToListAsync();
}
}