Skip to content

Commit f0b4a8c

Browse files
authored
Merge pull request #5 from feO2x/features/new-data-access-abstractions
Overhaul DatabaseAccessAbstractions
2 parents bdc4817 + d5a9e3e commit f0b4a8c

File tree

7 files changed

+16
-161
lines changed

7 files changed

+16
-161
lines changed

Code/Light.SharedCore/DatabaseAccessAbstractions/IAsyncReadOnlySession.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

Code/Light.SharedCore/DatabaseAccessAbstractions/IAsyncSession.cs

Lines changed: 0 additions & 31 deletions
This file was deleted.

Code/Light.SharedCore/DatabaseAccessAbstractions/IAsyncTransaction.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

Code/Light.SharedCore/DatabaseAccessAbstractions/IAsyncTransactionalSession.cs

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
using System;
2+
using System.Threading;
3+
using System.Threading.Tasks;
24

35
namespace Light.SharedCore.DatabaseAccessAbstractions;
46

57
/// <summary>
68
/// <para>
7-
/// PLEASE REMEMBER: database calls should be performed asynchronously
8-
/// by default, especially in service apps to avoid blocking threads.
9-
/// Consider using the <see cref="IAsyncSession" /> interface instead.
9+
/// Represents the base interface for an asynchronous session to a database that manipulates data. This means that
10+
/// the implementation will either use a single dedicated transaction in the case of ADO.NET or Micro-ORMs
11+
/// to ensure ACID properties, or the change tracking capabilities of a full ORM like Entity Framework Core.
1012
/// </para>
1113
/// <para>
12-
/// Represents a synchronous session to a database. This means that
13-
/// the implementation will either use a single dedicated transaction in the case of ADO.NET or Micro-ORMs
14-
/// to ensure ACID properties, or the Change Tracking capabilities of a full ORM like Entity Framework Core. The
15-
/// connection to the database can be terminated by calling
16-
/// <see cref="IDisposable.Dispose" />. Changes can be saved or committed
17-
/// to the database by calling <see cref="SaveChanges" />.
18-
/// If your session does not manipulate data, consider deriving your session abstraction from
19-
/// the <see cref="IDisposable" /> interface instead.
14+
/// The connection to the database can be terminated by calling
15+
/// <see cref="IAsyncDisposable.DisposeAsync" />, the underlying transaction
16+
/// will be automatically rolled back if <see cref="SaveChangesAsync" /> was not called beforehand.
17+
/// </para>
18+
/// <para>
19+
/// If you don't want the caller to explicitly commit the changes, consider deriving your session from
20+
/// <see cref="IAsyncDisposable"/> directly.
2021
/// </para>
2122
/// </summary>
2223
/// <remarks>
@@ -26,10 +27,11 @@ namespace Light.SharedCore.DatabaseAccessAbstractions;
2627
/// to do Change Tracking which plain ADO.NET and all Micro-ORMs do not support. For this reason,
2728
/// we chose the term "session" instead of "Unit of Work", also because it is simpler to use in daily life.
2829
/// </remarks>
29-
public interface ISession : IDisposable
30+
public interface ISession : IAsyncDisposable
3031
{
3132
/// <summary>
32-
/// Writes or commits all changes that occurred during the session to the target database.
33+
/// Commits all changes to the database.
3334
/// </summary>
34-
void SaveChanges();
35+
/// <param name="cancellationToken">The token to cancel this asynchronous operation (optional).</param>
36+
Task SaveChangesAsync(CancellationToken cancellationToken = default);
3537
}

Code/Light.SharedCore/DatabaseAccessAbstractions/ITransaction.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

Code/Light.SharedCore/DatabaseAccessAbstractions/ITransactionalSession.cs

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)