@@ -7,6 +7,14 @@ namespace SQLitePCL.pretty.Orm
77{
88 public static partial class TableMapping
99 {
10+
11+ /// <summary>
12+ /// Prepares a SQLite statement that can be bound to an object primary key to delete row from the database.
13+ /// </summary>
14+ /// <returns>A prepared statement.</returns>
15+ /// <param name="This">The database connection</param>
16+ /// <param name="tableMapping">The table mapping.</param>
17+ /// <typeparam name="T">The mapped type</typeparam>
1018 public static ITableMappedStatement < T > PrepareDeleteStatement < T > ( this IDatabaseConnection This , ITableMapping < T > tableMapping )
1119 {
1220 return new TableMappedStatement < T > (
@@ -31,6 +39,15 @@ private static IEnumerable<KeyValuePair<long,T>> YieldDeleteAll<T>(this IDatabas
3139 }
3240 }
3341
42+ /// <summary>
43+ /// Tries to delete the object in the database with the provided primary key.
44+ /// </summary>
45+ /// <returns><c>true</c>, if an object was found and deleted, <c>false</c> otherwise.</returns>
46+ /// <param name="This">The database connection.</param>
47+ /// <param name="tableMapping">The table mapping.</param>
48+ /// <param name="primaryKey">A primary key.</param>
49+ /// <param name="deleted">If found in the database, the deleted object.</param>
50+ /// <typeparam name="T">The mapped type.</typeparam>
3451 public static bool TryDelete < T > ( this IDatabaseConnection This , ITableMapping < T > tableMapping , long primaryKey , out T deleted )
3552 {
3653 var result = This . YieldDeleteAll ( tableMapping , new long [ ] { primaryKey } ) . FirstOrDefault ( ) ;
@@ -45,7 +62,15 @@ public static bool TryDelete<T>(this IDatabaseConnection This, ITableMapping<T>
4562 return false ;
4663 }
4764 }
48-
65+
66+ /// <summary>
67+ /// Deleted all object instances specified by their primary keys.
68+ /// </summary>
69+ /// <returns>A dictionary mapping the primary key to its value if found in the database.</returns>
70+ /// <param name="This">The database connection.</param>
71+ /// <param name="tableMapping">The table mapping.</param>
72+ /// <param name="primaryKeys">An IEnumerable of primary keys to delete.</param>
73+ /// <typeparam name="T">The mapped type.</typeparam>
4974 public static IReadOnlyDictionary < long , T > DeleteAll < T > ( this IDatabaseConnection This , ITableMapping < T > tableMapping , IEnumerable < long > primaryKeys )
5075 {
5176 return This . RunInTransaction ( _ =>
@@ -54,26 +79,64 @@ public static IReadOnlyDictionary<long,T> DeleteAll<T>(this IDatabaseConnection
5479 . ToDictionary ( kvp => kvp . Key , kvp => kvp . Value ) ) ;
5580 }
5681
82+ /// <summary>
83+ /// Deletes all object instances specified by their primary keys.
84+ /// </summary>
85+ /// <returns>A task that completes with a dictionary mapping the primary key to its value if found in the database.</returns>
86+ /// <param name="This">The database connection.</param>
87+ /// <param name="tableMapping">The table mapping.</param>
88+ /// <param name="primaryKeys">An IEnumerable of primary keys to delete.</param>
89+ /// <param name="ct">A cancellation token that can be used to cancel the operation.</param>
90+ /// <typeparam name="T">The mapped type.</typeparam>
5791 public static Task < IReadOnlyDictionary < long , T > > DeleteAllAsync < T > ( this IAsyncDatabaseConnection This , ITableMapping < T > tableMapping , IEnumerable < long > primaryKeys , CancellationToken ct )
5892 {
5993 return This . Use ( ( db , _ ) => db . DeleteAll < T > ( tableMapping , primaryKeys ) , ct ) ;
6094 }
6195
96+ /// <summary>
97+ /// Deletes all object instances specified by their primary keys.
98+ /// </summary>
99+ /// <returns>A task that completes with a dictionary mapping the primary key to its value if found in the database.</returns>
100+ /// <param name="This">The database connection.</param>
101+ /// <param name="tableMapping">The table mapping.</param>
102+ /// <param name="primaryKeys">An IEnumerable of primary keys to delete.</param>
103+ /// <typeparam name="T">The mapped type.</typeparam>
62104 public static Task < IReadOnlyDictionary < long , T > > DeleteAllAsync < T > ( this IAsyncDatabaseConnection This , ITableMapping < T > tableMapping , IEnumerable < long > primaryKeys )
63105 {
64106 return This . DeleteAllAsync ( tableMapping , primaryKeys , CancellationToken . None ) ;
65107 }
66108
109+ /// <summary>
110+ /// Deletes all rows in a given table.
111+ /// </summary>
112+ /// <param name="This">The database connection.</param>
113+ /// <param name="tableMapping">The table mapping.</param>
114+ /// <typeparam name="T">The mapped type.</typeparam>
67115 public static void DeleteAllRows < T > ( this IDatabaseConnection This , ITableMapping < T > tableMapping )
68116 {
69117 This . DeleteAll ( tableMapping . TableName ) ;
70118 }
71119
120+ /// <summary>
121+ /// Deletes all rows in a given table, asynchronously.
122+ /// </summary>
123+ /// <returns>A task that completes when all rows are deleted succesfully.</returns>
124+ /// <param name="This">The database connection.</param>
125+ /// <param name="tableMapping">he table mapping.</param>
126+ /// <param name="ct">A cancellation token that can be used to cancel the operation.</param>
127+ /// <typeparam name="T">The mapped type.</typeparam>
72128 public static Task DeleteAllRowsAsync < T > ( this IAsyncDatabaseConnection This , ITableMapping < T > tableMapping , CancellationToken ct )
73129 {
74130 return This . Use ( ( db , _ ) => db . DeleteAllRows ( tableMapping ) , ct ) ;
75131 }
76132
133+ /// <summary>
134+ /// Deletes all rows in a given table, asynchronously.
135+ /// </summary>
136+ /// <returns>A task that completes when all rows are deleted succesfully.</returns>
137+ /// <param name="This">The database connection.</param>
138+ /// <param name="tableMapping">he table mapping.</param>
139+ /// <typeparam name="T">The mapped type.</typeparam>
77140 public static Task DeleteAllRowsAsync < T > ( this IAsyncDatabaseConnection This , ITableMapping < T > tableMapping )
78141 {
79142 return This . DeleteAllRowsAsync ( tableMapping , CancellationToken . None ) ;
0 commit comments