johelvisguzman / DotNetToolkit.Repository

A toolkit for using the Repository pattern in C# .NET
MIT License
8 stars 5 forks source link

Use a callback to configure conventions for a context #693

Open johelvisguzman opened 2 years ago

johelvisguzman commented 2 years ago

Instead of overriding the convention property we should probably use a callback instead. That way there is more flexibility and freedom.

The following will need to be revised:

.../src/DotNetToolkit.Repository/RepositoryBase.cs

private void ConfigureContext(IRepositoryContext context)
{
    Guard.EnsureNotNull(context.Conventions, "No conventions have been configured for this context.");

    if (_options.Conventions != null)
        RepositoryConventions.Combine(_options.Conventions, context.Conventions);

    if (_loggerProvider != null)
        context.LoggerProvider = _loggerProvider;

    context.Conventions.ThrowsIfInvalidPrimaryKeyDefinition<TEntity>();
}