Skip to content

Commit 0d62da9

Browse files
committed
[#485] [add] impl
1 parent e68c404 commit 0d62da9

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

src/Simplify.Repository.EntityFramework/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [0.3.0] - 2023-01-14
44

5+
### Added
6+
7+
- Make UnitOfWork.Session protected set to be able to change behavior on child classes (#485)
8+
59
### Dependencies
610

711
- Simplify.Repository bump to 1.7

src/Simplify.Repository.EntityFramework/UnitOfWork.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,22 @@ namespace Simplify.Repository.EntityFramework;
66
/// <summary>
77
/// Provides unit of work
88
/// </summary>
9-
public class UnitOfWork<T> : IUnitOfWork
9+
/// <remarks>
10+
/// Initializes a new instance of the <see cref="UnitOfWork{T}" /> class.
11+
/// </remarks>
12+
/// <param name="context">The context.</param>
13+
/// <exception cref="InvalidOperationException">Error opening session, session is null</exception>
14+
public class UnitOfWork<T>(DbContext context) : IUnitOfWork
1015
where T : DbContext
1116
{
12-
/// <summary>
13-
/// Initializes a new instance of the <see cref="UnitOfWork{T}" /> class.
14-
/// </summary>
15-
/// <param name="context">The context.</param>
16-
/// <exception cref="System.InvalidOperationException">Error opening session, session is null</exception>
17-
public UnitOfWork(DbContext context) => Context = context ?? throw new InvalidOperationException("Error opening session, session is null");
1817

1918
/// <summary>
2019
/// Gets the session.
2120
/// </summary>
2221
/// <value>
2322
/// The session.
2423
/// </value>
25-
public DbContext Context { get; }
24+
public DbContext Context { get; protected set; } = context ?? throw new InvalidOperationException("Error opening session, session is null");
2625

2726
/// <summary>
2827
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

src/Simplify.Repository.FluentNHibernate/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [1.7.0] - 2024-01-14
44

5+
### Added
6+
7+
- Make UnitOfWork.Session protected set to be able to change behavior on child classes (#485)
8+
59
### Dependencies
610

711
- Simplify.Repository bump to 1.7

src/Simplify.Repository.FluentNHibernate/UnitOfWork.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,20 @@ namespace Simplify.Repository.FluentNHibernate;
66
/// <summary>
77
/// Provides unit of work
88
/// </summary>
9-
public class UnitOfWork : IUnitOfWork
9+
/// <remarks>
10+
/// Initializes a new instance of the <see cref="UnitOfWork"/> class.
11+
/// </remarks>
12+
/// <param name="sessionFactory">The session factory.</param>
13+
public class UnitOfWork(ISessionFactory sessionFactory) : IUnitOfWork
1014
{
11-
/// <summary>
12-
/// Initializes a new instance of the <see cref="UnitOfWork"/> class.
13-
/// </summary>
14-
/// <param name="sessionFactory">The session factory.</param>
15-
public UnitOfWork(ISessionFactory sessionFactory) =>
16-
Session = sessionFactory.OpenSession() ?? throw new InvalidOperationException("Error opening session, session is null");
1715

1816
/// <summary>
1917
/// Gets the session.
2018
/// </summary>
2119
/// <value>
2220
/// The session.
2321
/// </value>
24-
public ISession Session { get; }
22+
public ISession Session { get; protected set; } = sessionFactory.OpenSession() ?? throw new InvalidOperationException("Error opening session, session is null");
2523

2624
/// <summary>
2725
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

0 commit comments

Comments
 (0)