Skip to content

Commit 6cba66b

Browse files
Changed the GetContext method to protected for more flexibility
1 parent d884b94 commit 6cba66b

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

src/DotNetToolkit.Repository/RepositoryBase.cs

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2971,6 +2971,29 @@ Task<IPagedQueryResult<IEnumerable<TResult>>> Getter() =>
29712971

29722972
#region Protected Methods
29732973

2974+
/// <summary>
2975+
/// Gets the repository context.
2976+
/// </summary>
2977+
/// <returns>The repository context.</returns>
2978+
protected virtual IRepositoryContext GetContext()
2979+
{
2980+
var context = _contextFactory.Create();
2981+
2982+
Guard.EnsureNotNull(context.Conventions, "No conventions have been configured for this context.");
2983+
2984+
if (_options.Conventions != null)
2985+
{
2986+
context.Conventions.Apply(_options.Conventions);
2987+
}
2988+
2989+
if (context.Logger == null || context.Logger is NullLogger)
2990+
{
2991+
context.Logger = LoggerProvider.Create(context.GetType().FullName);
2992+
}
2993+
2994+
return context;
2995+
}
2996+
29742997
/// <summary>
29752998
/// Override this method to configure the repository.
29762999
/// </summary>
@@ -3205,25 +3228,6 @@ private IEnumerable<IRepositoryInterceptor> GetInterceptors()
32053228
return _interceptors;
32063229
}
32073230

3208-
private IRepositoryContext GetContext()
3209-
{
3210-
var context = _contextFactory.Create();
3211-
3212-
Guard.EnsureNotNull(context.Conventions, "No conventions have been configured for this context.");
3213-
3214-
if (_options.Conventions != null)
3215-
{
3216-
context.Conventions.Apply(_options.Conventions);
3217-
}
3218-
3219-
if (context.Logger == null || context.Logger is NullLogger)
3220-
{
3221-
context.Logger = LoggerProvider.Create(context.GetType().FullName);
3222-
}
3223-
3224-
return context;
3225-
}
3226-
32273231
private static void DisposeContext([CanBeNull] IRepositoryContext context)
32283232
{
32293233
if (context != null && context.CurrentTransaction == null)

0 commit comments

Comments
 (0)