5
5
using System . Threading . Tasks ;
6
6
7
7
/// <summary>
8
- /// Provides basic DDL and CRUD command definitions and a DI-supplied Context
8
+ /// Provides basic DDL and CRUD command definitions and a DI-supplied Context.
9
9
/// </summary>
10
10
public interface ILiteDbSet
11
11
{
@@ -48,17 +48,84 @@ public interface ILiteDbSet
48
48
/// Gets the delete definition where.
49
49
/// </summary>
50
50
string DeleteDefinitionWhere { get ; }
51
+
52
+ /// <summary>
53
+ /// Gets any definition.
54
+ /// </summary>
55
+ string AnyDefinition { get ; }
51
56
52
57
/// <summary>
53
58
/// Gets or sets the parent set context.
54
59
/// </summary>
55
60
LiteDbContext Context { get ; set ; }
61
+
62
+ /// <summary>
63
+ /// Provides and asynchronous counterpart to the Count method.
64
+ /// </summary>
65
+ /// <returns>A Task with the total number of rows.</returns>
66
+ Task < int > CountAsync ( ) ;
67
+
68
+ /// <summary>
69
+ /// Counts the total number of rows in the table.
70
+ /// </summary>
71
+ /// <returns>
72
+ /// The total number of rows.
73
+ /// </returns>
74
+ int Count ( ) ;
75
+
76
+ /// <summary>
77
+ /// Provides and asynchronous counterpart to the Count method.
78
+ /// </summary>
79
+ /// <param name="whereText">The where text.</param>
80
+ /// <param name="whereParams">The where parameters.</param>
81
+ /// <returns>
82
+ /// A Task with the total number of rows.
83
+ /// </returns>
84
+ Task < int > CountAsync ( string whereText , object whereParams = null ) ;
85
+
86
+ /// <summary>
87
+ /// Provides and asynchronous counterpart to the Count method.
88
+ /// </summary>
89
+ /// <param name="whereText">The where text.</param>
90
+ /// <param name="whereParams">The where parameters.</param>
91
+ /// <returns>
92
+ /// The total number of rows.
93
+ /// </returns>
94
+ int Count ( string whereText , object whereParams = null ) ;
95
+
96
+ /// <summary>
97
+ /// Check if the row exist in the table.
98
+ /// </summary>
99
+ /// <returns><c>true</c> if the query contains data, otherwise <c>false</c>.</returns>
100
+ bool Any ( ) ;
101
+
102
+ /// <summary>
103
+ /// Check if the row exist in the table.
104
+ /// </summary>
105
+ /// <param name="whereText">The where text.</param>
106
+ /// <param name="whereParams">The where parameters.</param>
107
+ /// <returns><c>true</c> if the query contains data, otherwise <c>false</c>.</returns>
108
+ bool Any ( string whereText , object whereParams = null ) ;
109
+
110
+ /// <summary>
111
+ /// Check asynchronous if the row exist in the table.
112
+ /// </summary>
113
+ /// <param name="whereText">The where text.</param>
114
+ /// <param name="whereParams">The where parameters.</param>
115
+ /// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
116
+ Task < bool > AnyAsync ( string whereText , object whereParams = null ) ;
117
+
118
+ /// <summary>
119
+ /// Check asynchronous if the table contains data.
120
+ /// </summary>
121
+ /// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
122
+ Task < bool > AnyAsync ( ) ;
56
123
}
57
124
58
125
/// <summary>
59
- /// Provides typed access to querying the database
126
+ /// Provides typed access to querying the database.
60
127
/// </summary>
61
- /// <typeparam name="T">The type of LiteModel</typeparam>
128
+ /// <typeparam name="T">The type of LiteModel. </typeparam>
62
129
public interface ILiteDbSet < T > : ILiteDbSet
63
130
where T : ILiteModel
64
131
{
@@ -103,39 +170,40 @@ public interface ILiteDbSet<T> : ILiteDbSet
103
170
/// Selects a single entity from the databse given its row id.
104
171
/// </summary>
105
172
/// <param name="rowId">The row identifier.</param>
106
- /// <returns>A generic type</returns>
173
+ /// <returns>A generic type. </returns>
107
174
T Single ( long rowId ) ;
108
175
109
176
/// <summary>
110
- /// Counts the total number of rows in the table
177
+ /// Inserts the specified entities.
111
178
/// </summary>
112
- /// <returns>The total number of rows</returns>
113
- int Count ( ) ;
179
+ /// <param name="entities">The entities.</param>
180
+ /// <exception cref="ArgumentNullException">entities.</exception>
181
+ void InsertRange ( IEnumerable < T > entities ) ;
114
182
115
183
/// <summary>
116
- /// Provides and asynchronous counterpart to the Insert method
184
+ /// Provides and asynchronous counterpart to the Insert method.
117
185
/// </summary>
118
186
/// <param name="entity">The entity.</param>
119
- /// <returns>A Task with the number of rows inserted</returns>
187
+ /// <returns>A Task with the number of rows inserted. </returns>
120
188
Task < int > InsertAsync ( T entity ) ;
121
189
122
190
/// <summary>
123
- /// Provides and asynchronous counterpart to the Delete method
191
+ /// Provides and asynchronous counterpart to the Delete method.
124
192
/// </summary>
125
193
/// <param name="entity">The entity.</param>
126
194
/// <returns>A Task with the number of rows deleted</returns>
127
195
Task < int > DeleteAsync ( T entity ) ;
128
196
129
197
/// <summary>
130
- /// Provides and asynchronous counterpart to the Update method
198
+ /// Provides and asynchronous counterpart to the Update method.
131
199
/// </summary>
132
200
/// <param name="entity">The entity.</param>
133
201
/// <returns>A Task with the number of rows updated</returns>
134
202
Task < int > UpdateAsync ( T entity ) ;
135
203
136
204
/// <summary>
137
205
/// Deletes the specified where text.
138
- /// Example whereText = "X = @X" and whereParames = new { X = "hello" }
206
+ /// Example whereText = "X = @X" and whereParames = new { X = "hello" }.
139
207
/// </summary>
140
208
/// <param name="whereText">The where text.</param>
141
209
/// <param name="whereParams">The where parameters.</param>
@@ -164,18 +232,30 @@ public interface ILiteDbSet<T> : ILiteDbSet
164
232
/// </summary>
165
233
/// <returns>A Task of type Enumerable with a generic type.</returns>
166
234
Task < IEnumerable < T > > SelectAllAsync ( ) ;
167
-
235
+
168
236
/// <summary>
169
237
/// Provides and asynchronous counterpart to the Single method.
170
238
/// </summary>
171
239
/// <param name="rowId">The row identifier.</param>
172
- /// <returns>A Task with a generyc type.</returns>
240
+ /// <returns>
241
+ /// A Task with a generyc type.
242
+ /// </returns>
173
243
Task < T > SingleAsync ( long rowId ) ;
174
244
175
245
/// <summary>
176
- /// Provides and asynchronous counterpart to the Count method .
246
+ /// Firsts the or default .
177
247
/// </summary>
178
- /// <returns>A Task with the total number of rows.</returns>
179
- Task < int > CountAsync ( ) ;
248
+ /// <param name="fieldName">Name of the field.</param>
249
+ /// <param name="fieldValue">The field value.</param>
250
+ /// <returns> A generic type</returns>
251
+ T FirstOrDefault ( string fieldName , object fieldValue ) ;
252
+
253
+ /// <summary>
254
+ /// Firsts the or default asynchronous.
255
+ /// </summary>
256
+ /// <param name="fieldName">Name of the field.</param>
257
+ /// <param name="fieldValue">The field value.</param>
258
+ /// <returns>A Task with a generic type.</returns>
259
+ Task < T > FirstOrDefaultAsync ( string fieldName , object fieldValue ) ;
180
260
}
181
261
}
0 commit comments