Skip to content

Commit 51d9827

Browse files
committed
add docs
1 parent f05db03 commit 51d9827

9 files changed

Lines changed: 143 additions & 29 deletions

SQLitePCL.pretty.Orm/DatabaseConnection.Delete.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static partial class DatabaseConnection
1919
/// </summary>
2020
/// <returns>A prepared statement.</returns>
2121
/// <param name="This">The database connection</param>
22-
/// <param name="tableMapping">The table mapping.</param>
22+
/// <typeparam name="T">The mapped type.</typeparam>
2323
public static IStatement PrepareDeleteStatement<T>(this IDatabaseConnection This)
2424
{
2525
Contract.Requires(This != null);
@@ -60,9 +60,9 @@ private static IEnumerable<KeyValuePair<long,T>> YieldDeleteAll<T>(
6060
/// </summary>
6161
/// <returns><c>true</c>, if an object was found and deleted, <c>false</c> otherwise.</returns>
6262
/// <param name="This">The database connection.</param>
63-
/// <param name="tableMapping">The table mapping.</param>
6463
/// <param name="primaryKey">A primary key.</param>
6564
/// <param name="deleted">If found in the database, the deleted object.</param>
65+
/// <param name="resultSelector">A transform function to apply to each row.</param>
6666
/// <typeparam name="T">The mapped type.</typeparam>
6767
public static bool TryDelete<T>(
6868
this IDatabaseConnection This,
@@ -91,8 +91,8 @@ public static bool TryDelete<T>(
9191
/// </summary>
9292
/// <returns>A dictionary mapping the primary key to its value if found in the database.</returns>
9393
/// <param name="This">The database connection.</param>
94-
/// <param name="tableMapping">The table mapping.</param>
9594
/// <param name="primaryKeys">An IEnumerable of primary keys to delete.</param>
95+
/// <param name="resultSelector">A transform function to apply to each row.</param>
9696
/// <typeparam name="T">The mapped type.</typeparam>
9797
public static IReadOnlyDictionary<long,T> DeleteAll<T>(
9898
this IDatabaseConnection This,
@@ -113,7 +113,7 @@ public static IReadOnlyDictionary<long,T> DeleteAll<T>(
113113
/// Drops the table if it exists. Otherwise this is a no-op.
114114
/// </summary>
115115
/// <param name="This">The database connection.</param>
116-
/// <param name="table">The table name.</param>
116+
/// <typeparam name="T">The mapped type.</typeparam>
117117
/// <seealso href="https://www.sqlite.org/lang_droptable.html"/>
118118
public static void DropTableIfExists<T>(this IDatabaseConnection This)
119119
{
@@ -128,7 +128,7 @@ public static void DropTableIfExists<T>(this IDatabaseConnection This)
128128
/// Deletes all rows in a given table.
129129
/// </summary>
130130
/// <param name="This">The database connection.</param>
131-
/// <param name="table">The table name.</param>
131+
/// <typeparam name="T">The mapped type.</typeparam>
132132
public static void DeleteAllRows<T>(this IDatabaseConnection This)
133133
{
134134
Contract.Requires(This != null);
@@ -145,8 +145,8 @@ public static partial class AsyncDatabaseConnection
145145
/// </summary>
146146
/// <returns>A task that completes with a dictionary mapping the primary key to its value if found in the database.</returns>
147147
/// <param name="This">The database connection.</param>
148-
/// <param name="tableMapping">The table mapping.</param>
149148
/// <param name="primaryKeys">An IEnumerable of primary keys to delete.</param>
149+
/// <param name="resultSelector">A transform function to apply to each row.</param>
150150
/// <param name="ct">A cancellation token that can be used to cancel the operation.</param>
151151
/// <typeparam name="T">The mapped type.</typeparam>
152152
public static Task<IReadOnlyDictionary<long,T>> DeleteAllAsync<T>(
@@ -167,8 +167,8 @@ public static Task<IReadOnlyDictionary<long,T>> DeleteAllAsync<T>(
167167
/// </summary>
168168
/// <returns>A task that completes with a dictionary mapping the primary key to its value if found in the database.</returns>
169169
/// <param name="This">The database connection.</param>
170-
/// <param name="tableMapping">The table mapping.</param>
171170
/// <param name="primaryKeys">An IEnumerable of primary keys to delete.</param>
171+
/// <param name="resultSelector">A transform function to apply to each row.</param>
172172
/// <typeparam name="T">The mapped type.</typeparam>
173173
public static Task<IReadOnlyDictionary<long,T>> DeleteAllAsync<T>(
174174
this IAsyncDatabaseConnection This,
@@ -187,9 +187,8 @@ public static Task<IReadOnlyDictionary<long,T>> DeleteAllAsync<T>(
187187
/// Drops the table if exists async.
188188
/// </summary>
189189
/// <returns>The table if exists async.</returns>
190-
/// <param name="This">This.</param>
191-
/// <param name="table">The table name.</param>
192-
/// <param name="ct">Ct.</param>
190+
/// <param name="This">The database connection.</param>
191+
/// <param name="ct">The cancellation token.</param>
193192
public static Task DropTableIfExistsAsync<T>(this IAsyncDatabaseConnection This, CancellationToken ct)
194193
{
195194
Contract.Requires(This != null);
@@ -201,8 +200,8 @@ public static Task DropTableIfExistsAsync<T>(this IAsyncDatabaseConnection This,
201200
/// Drops the table if exists async.
202201
/// </summary>
203202
/// <returns>The table if exists async.</returns>
204-
/// <param name="This">This.</param>
205-
/// <param name="table">The table name.</param>
203+
/// <param name="This">The database connection.</param>
204+
/// <typeparam name="T">The mapped type.</typeparam>
206205
public static Task DropTableIfExistsAsync<T>(this IAsyncDatabaseConnection This)
207206
{
208207
Contract.Requires(This != null);
@@ -214,8 +213,8 @@ public static Task DropTableIfExistsAsync<T>(this IAsyncDatabaseConnection This)
214213
/// </summary>
215214
/// <returns>A task that completes when all rows are deleted succesfully.</returns>
216215
/// <param name="This">The database connection.</param>
217-
/// <param name="table">The table name.</param>
218216
/// <param name="ct">A cancellation token that can be used to cancel the operation.</param>
217+
/// <typeparam name="T">The mapped type.</typeparam>
219218
public static Task DeleteAllRowsAsync<T>(this IAsyncDatabaseConnection This, CancellationToken ct)
220219
{
221220
Contract.Requires(This != null);
@@ -227,7 +226,7 @@ public static Task DeleteAllRowsAsync<T>(this IAsyncDatabaseConnection This, Can
227226
/// </summary>
228227
/// <returns>A task that completes when all rows are deleted succesfully.</returns>
229228
/// <param name="This">The database connection.</param>
230-
/// <param name="table">The table name.</param>
229+
/// <typeparam name="T">The mapped type.</typeparam>
231230
public static Task DeleteAllRowsAsync<T>(this IAsyncDatabaseConnection This)
232231
{
233232
Contract.Requires(This != null);

SQLitePCL.pretty.Orm/DatabaseConnection.Find.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static partial class DatabaseConnection
1818
/// </summary>
1919
/// <returns>A prepared statement.</returns>
2020
/// <param name="This">The database connection</param>
21-
/// <param name="tableMapping">The table mapping.</param>
21+
/// <typeparam name="T">The mapped type.</typeparam>
2222
public static IStatement PrepareFindStatement<T>(this IDatabaseConnection This)
2323
{
2424
Contract.Requires(This != null);
@@ -53,9 +53,9 @@ private static IEnumerable<KeyValuePair<long,T>> YieldFindAll<T>(
5353
/// </summary>
5454
/// <returns><c>true</c>, if an object was found, <c>false</c> otherwise.</returns>
5555
/// <param name="This">The database connection.</param>
56-
/// <param name="tableMapping">The table mapping.</param>
5756
/// <param name="primaryKey">A primary key.</param>
5857
/// <param name="value">If found in the database, the found object.</param>
58+
/// <param name="resultSelector">A transform function to apply to each row.</param>
5959
/// <typeparam name="T">The mapped type.</typeparam>
6060
public static bool TryFind<T>(
6161
this IDatabaseConnection This,
@@ -83,8 +83,8 @@ public static bool TryFind<T>(
8383
/// </summary>
8484
/// <returns>A dictionary mapping the primary key to its value if found in the database.</returns>
8585
/// <param name="This">The database connection.</param>
86-
/// <param name="tableMapping">The table mapping.</param>
8786
/// <param name="primaryKeys">An IEnumerable of primary keys to find.</param>
87+
/// <param name="resultSelector">A transform function to apply to each row.</param>
8888
/// <typeparam name="T">The mapped type.</typeparam>
8989
public static IReadOnlyDictionary<long,T> FindAll<T>(
9090
this IDatabaseConnection This,
@@ -101,15 +101,18 @@ public static IReadOnlyDictionary<long,T> FindAll<T>(
101101
}
102102
}
103103

104+
/// <summary>
105+
/// Extension methods for instances of <see cref="SQLitePCL.pretty.IAsyncDatabaseConnection"/>.
106+
/// </summary>
104107
public static partial class AsyncDatabaseConnection
105108
{
106109
/// <summary>
107110
/// Finds all object instances specified by their primary keys.
108111
/// </summary>
109112
/// <returns>A task that completes with a dictionary mapping the primary key to its value if found in the database.</returns>
110113
/// <param name="This">The database connection.</param>
111-
/// <param name="tableMapping">The table mapping.</param>
112114
/// <param name="primaryKeys">An IEnumerable of primary keys to find.</param>
115+
/// <param name="resultSelector">A transform function to apply to each row.</param>
113116
/// <param name="ct">A cancellation token that can be used to cancel the operation</param>
114117
/// <typeparam name="T">The mapped type.</typeparam>
115118
public static Task<IReadOnlyDictionary<long,T>> FindAllAsync<T>(
@@ -130,8 +133,8 @@ public static Task<IReadOnlyDictionary<long,T>> FindAllAsync<T>(
130133
/// </summary>
131134
/// <returns>A task that completes with a dictionary mapping the primary key to its value if found in the database.</returns>
132135
/// <param name="This">The database connection.</param>
133-
/// <param name="tableMapping">The table mapping.</param>
134136
/// <param name="primaryKeys">An IEnumerable of primary keys to find.</param>
137+
/// <param name="resultSelector">A transform function to apply to each row.</param>
135138
/// <typeparam name="T">The mapped type.</typeparam>
136139
public static Task<IReadOnlyDictionary<long,T>> FindAllAsync<T>(
137140
this IAsyncDatabaseConnection This,

SQLitePCL.pretty.Orm/DatabaseConnection.InsertOrReplace.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@ public static partial class DatabaseConnection
1818
/// </summary>
1919
/// <returns>A prepared statement.</returns>
2020
/// <param name="This">The database connection</param>
21-
/// <param name="tableMapping">The table mapping.</param>
21+
/// <typeparam name="T">The mapped type.</typeparam>
2222
public static IStatement PrepareInsertOrReplaceStatement<T>(this IDatabaseConnection This)
2323
{
2424
Contract.Requires(This != null);
2525

2626
var sql = insertOrReplaceQueries.GetValue(TableMapping.Get<T>(), mapping =>
2727
{
28-
var column = mapping.PrimaryKeyColumn();
2928
return SQLBuilder.InsertOrReplace(mapping.TableName, mapping.Columns.Select(x => x.Key));
3029
});
3130

@@ -54,9 +53,9 @@ private static IEnumerable<KeyValuePair<T,T>> YieldInsertOrReplaceAll<T>(
5453
/// </summary>
5554
/// <returns>The object inserted into the database including it's primary key.</returns>
5655
/// <param name="This">The database connection.</param>
57-
/// <param name="tableMapping">The table mapping.</param>
5856
/// <param name="obj">The object to insert.</param>
59-
/// <typeparam name="T">The mapped type.</typeparam>
57+
/// <param name="resultSelector">A transform function to apply to each row.</param>
58+
/// <typeparam name="T">The mapped type.</typeparam>
6059
public static T InsertOrReplace<T>(
6160
this IDatabaseConnection This,
6261
T obj,
@@ -74,8 +73,8 @@ public static T InsertOrReplace<T>(
7473
/// </summary>
7574
/// <returns>A dictionary mapping the provided objects to the objects that were inserted into the database.</returns>
7675
/// <param name="This">The database connection.</param>
77-
/// <param name="tableMapping">The table mapping.</param>
7876
/// <param name="objects">The objects to be inserted into the database.</param>
77+
/// <param name="resultSelector">A transform function to apply to each row.</param>
7978
/// <typeparam name="T">The mapped type.</typeparam>
8079
public static IReadOnlyDictionary<T,T> InsertOrReplaceAll<T>(
8180
this IDatabaseConnection This,
@@ -99,8 +98,8 @@ public static partial class AsyncDatabaseConnection
9998
/// </summary>
10099
/// <returns>A Task that completes with a dictionary mapping the provided objects to the objects that were inserted into the database.</returns>
101100
/// <param name="This">The database connection.</param>
102-
/// <param name="tableMapping">The table mapping.</param>
103101
/// <param name="objects">The objects to be inserted into the database.</param>
102+
/// <param name="resultSelector">A transform function to apply to each row.</param>
104103
/// <param name="ct">A cancellation token that can be used to cancel the operation</param>
105104
/// <typeparam name="T">The mapped type.</typeparam>
106105
public static Task<IReadOnlyDictionary<T,T>> InsertOrReplaceAllAsync<T>(
@@ -121,8 +120,8 @@ public static Task<IReadOnlyDictionary<T,T>> InsertOrReplaceAllAsync<T>(
121120
/// </summary>
122121
/// <returns>A Task that completes with a dictionary mapping the provided objects to the objects that were inserted into the database.</returns>
123122
/// <param name="This">The database connection.</param>
124-
/// <param name="tableMapping">The table mapping.</param>
125123
/// <param name="objects">The objects to be inserted into the database.</param>
124+
/// <param name="resultSelector">A transform function to apply to each row.</param>
126125
/// <typeparam name="T">The mapped type.</typeparam>
127126
public static Task<IReadOnlyDictionary<T,T>> InsertOrReplaceAllAsync<T>(
128127
this IAsyncDatabaseConnection This,

SQLitePCL.pretty.Orm/DatabaseConnection.Query.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,40 @@ namespace SQLitePCL.pretty.Orm
66
{
77
public static partial class DatabaseConnection
88
{
9+
/// <summary>
10+
/// Compiles a SQL query.
11+
/// </summary>
12+
/// <param name="This">The database connection.</param>
13+
/// <param name="query">The SQL query to compile.</param>
14+
/// <returns>The compiled statement.</returns>
915
public static IStatement PrepareStatement(this IDatabaseConnection This, ISqlQuery query)
1016
{
1117
Contract.Requires(This != null);
1218
Contract.Requires(query != null);
1319
return This.PrepareStatement(query.ToString());
1420
}
1521

22+
/// <summary>
23+
/// Compiles a SQL query, returning the an <see cref="IEnumerable&lt;T&gt;"/> of rows in the result set.
24+
/// </summary>
25+
/// <param name="This">The database connection.</param>
26+
/// <param name="query">The SQL statement to compile and Query.</param>
27+
/// <returns>An <see cref="IEnumerable&lt;T&gt;"/> of rows in the result set.</returns>
1628
public static IEnumerable<IReadOnlyList<IResultSetValue>> Query(this IDatabaseConnection This, ISqlQuery query)
1729
{
1830
Contract.Requires(This != null);
1931
Contract.Requires(query != null);
2032
return This.Query(query.ToString());
2133
}
2234

35+
/// <summary>
36+
/// Compiles a SQL statement with provided bind parameter values,
37+
/// returning the an <see cref="IEnumerable&lt;T&gt;"/> of rows in the result set.
38+
/// </summary>
39+
/// <param name="This">The database connection.</param>
40+
/// <param name="query">The SQL statement to compile and Query.</param>
41+
/// <param name="values">The bind parameter values.</param>
42+
/// <returns>An <see cref="IEnumerable&lt;T&gt;"/> of rows in the result set.</returns>
2343
public static IEnumerable<IReadOnlyList<IResultSetValue>> Query(
2444
this IDatabaseConnection This, ISqlQuery query, params object[] values)
2545
{
@@ -32,13 +52,29 @@ public static IEnumerable<IReadOnlyList<IResultSetValue>> Query(
3252

3353
public static partial class AsyncDatabaseConnection
3454
{
55+
/// <summary>
56+
/// Returns a cold observable that compiles a SQL query
57+
/// that publishes the rows in the result set for each subscription.
58+
/// </summary>
59+
/// <param name="This">The asynchronous database connection.</param>
60+
/// <param name="query">The SQL query to compile and Query.</param>
61+
/// <returns>A cold observable of rows in the result set.</returns>
3562
public static IObservable<IReadOnlyList<IResultSetValue>> Query(this IAsyncDatabaseConnection This, ISqlQuery query)
3663
{
3764
Contract.Requires(This != null);
3865
Contract.Requires(query != null);
3966
return This.Query(query.ToString());
4067
}
4168

69+
/// <summary>
70+
/// Returns a cold observable that compiles a SQL query with
71+
/// provided bind parameter values, that publishes the rows in the result
72+
/// set for each subscription.
73+
/// </summary>
74+
/// <param name="This">The asynchronous database connection.</param>
75+
/// <param name="query">The SQL query to compile and Query.</param>
76+
/// <param name="values">The bind parameter values.</param>
77+
/// <returns>A cold observable of rows in the result set.</returns>
4278
public static IObservable<IReadOnlyList<IResultSetValue>> Query(
4379
this IAsyncDatabaseConnection This, ISqlQuery query, params object[] values)
4480
{

SQLitePCL.pretty.Orm/DatabaseConnection.Tables.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static partial class DatabaseConnection
3131
/// Creates or migrate a table in the database for the given table mapping, creating indexes if needed.
3232
/// </summary>
3333
/// <param name="This">The database connection.</param>
34-
/// <param name="tableMapping">The table mapping.</param>
34+
/// <typeparam name="T">The mapped type.</typeparam>
3535
public static void InitTable<T>(this IDatabaseConnection This)
3636
{
3737
Contract.Requires(This != null);
@@ -79,8 +79,8 @@ public static partial class AsyncDatabaseConnection
7979
/// </summary>
8080
/// <returns>A task that completes once the table is succesfully created and is ready for use.</returns>
8181
/// <param name="This">The database connection</param>
82-
/// <param name="tableMapping">The table mapping.</param>
8382
/// <param name="cancellationToken">A cancellation token that can be used to cancel the operation.</param>
83+
/// <typeparam name="T">The mapped type.</typeparam>
8484
public static Task InitTableAsync<T>(this IAsyncDatabaseConnection This, CancellationToken cancellationToken)
8585
{
8686
Contract.Requires(This != null);
@@ -92,7 +92,7 @@ public static Task InitTableAsync<T>(this IAsyncDatabaseConnection This, Cancell
9292
/// </summary>
9393
/// <returns>A task that completes once the table is succesfully created and is ready for use.</returns>
9494
/// <param name="This">The database connection</param>
95-
/// <param name="tableMapping">The table mapping.</param>
95+
/// <typeparam name="T">The mapped type.</typeparam>
9696
public static Task InitTableAsync<T>(this IAsyncDatabaseConnection This)
9797
{
9898
Contract.Requires(This != null);

SQLitePCL.pretty.Orm/DatabaseConnection.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ internal enum CreateFlags
3636
FullTextSearch4 = 0x200 // create virtual table using FTS4
3737
}
3838

39+
/// <summary>
40+
/// Extensions methods for instances of <see cref="SQLitePCL.pretty.IDatabaseConnection"/>.
41+
/// </summary>
3942
public static partial class DatabaseConnection
4043
{
4144
internal static void CreateTableIfNotExists(this IDatabaseConnection conn, string tableName, CreateFlags createFlags, IReadOnlyDictionary<string, ColumnMapping> columns)

0 commit comments

Comments
 (0)