Restructure code for improved readability and maintainability. Move RepositoryConfiguration as a nested public class inside DependencyInjection, group related service registration logic, and clarify method organization. No functional changes.
Changed RegisterDefaultRepository to register repositories by DbContext only, removing the entity-specific generic parameter. Added a private InvokeAll<T> helper to process queued service registrations. This streamlines repository registration and improves code maintainability.
DbRepository<TDbContext> now implements the IRepository interface, ensuring it conforms to the expected repository contract and interface requirements. This change improves consistency and enforces interface adherence across repository implementations.
Extended IRepository interfaces and DbRepository implementation to support raw and interpolated SQL query execution (sync/async) and querying. Updated DependencyInjection to allow registration of default repository implementations. Added Microsoft.EntityFrameworkCore.Abstractions as a dependency. Performed minor refactoring and cleanup.
Removed conditional compilation around the namespace in DbRepository.cs, making it always use standard braces. Added System.Linq using directive to support LINQ operations.
Added a `RegsRepository` queue to manage repository registrations.
Introduced `RegisterDefaultRepository<TDbContext, TEntity>()` to
enqueue scoped repository registrations. Updated `RegisterAllServices`
to process the `RegsRepository` queue during service registration.
Added `QueryRaw` and `QueryInterpolated` methods to the
`IRepository` interface for raw and interpolated SQL queries,
conditionally compiled for the `NET` target framework.
Removed the `Sql` method from `DbRepository` and replaced it
with implementations of `QueryRaw` and `QueryInterpolated`
using `Entities.FromSqlRaw` and `Entities.FromSqlInterpolated`.
Updated the `Query` property in `DbRepository` to use
`Entities.AsNoTracking()` for read-only queries.
The `DbRepository` class now enforces that the generic type
parameter `TDbContext` must implement the `IRepository`
interface in addition to inheriting from `DbContext`. This
ensures that `DbRepository` can leverage functionality
provided by the `IRepository` interface, improving type
safety and consistency.
Added `ExecuteSqlRawAsync` and `ExecuteSqlInterpolatedAsync` methods to the `DbRepository` class for asynchronous SQL execution. Updated the `System.Linq` namespace import to support LINQ operations. Simplified conditional compilation directives by consistently enclosing the class declaration in braces `{}` across frameworks. Adjusted closing braces to align with the updated structure.
Introduced DbRepository<TDbContext> to provide basic database operations, including methods for executing raw SQL commands via ExecuteSqlRaw and ExecuteSqlInterpolated. The class exposes the underlying DbContext for use in derived classes. Existing DbRepository<TDbContext, TEntity> remains unchanged.
Added a Sql method to DbRepository for executing raw SQL queries
via FromSqlRaw. Included Microsoft.EntityFrameworkCore.Relational
package references for all target frameworks to support this
functionality. Cleaned up unused using directives.
- Introduced Action<TEntity>-based UpdateAsync method for more flexible updates
- Updated TDto-based UpdateAsync to delegate to the new method
- Reduced code duplication and Mapper dependency
- Preserved existing Create, Read, and Delete functionality
Updated `DigitalData.Core.Abstraction.Application` to version 1.3.3 and `DigitalData.Core.Infrastructure` to version 2.4.3. These changes reflect minor updates, likely including bug fixes and small enhancements.
Added preprocessor directives to conditionally include
code for different .NET frameworks. Adjusted namespace
declarations and organized the `Static` class for
improved clarity and maintainability.
Updated the `Static` class in the `DigitalData.Core.Infrastructure` namespace to a generic version `Static<TEntity>`. Removed the original non-generic class and the `GetRepository<TEntity>` method. The new generic class provides a method to retrieve a repository for a specific entity type `TEntity`, enhancing type safety and usability.
Updated the exception message in the `Static` class to clarify that services cannot be accessed after the service provider has been created. This change enhances the clarity of the error for developers.
This commit introduces two new properties in the `Static` class: `Repository` and `GetRepository<TEntity>()`. The `Repository` property allows retrieval of an `IRepository` instance from the service provider, while `GetRepository<TEntity>()` provides access to a specific `IRepository<TEntity>`. These additions improve the ease of accessing repository instances for data operations.
Introduce framework-specific handling in `Static.cs` to support both NET and NETFRAMEWORK. Implement lazy initialization for service collection and provider, ensuring proper access and error handling.
Updated code to support conditional compilation for .NET Framework and .NET.
Introduced nullable reference types in `DbRepository.cs` and ensured proper initialization of service registration queues in `DependencyInjection.cs`.
Modified `DbRepositoryFactory.cs` and `DbSetFactory.cs` to maintain consistent structure across frameworks.
These changes enhance compatibility and improve type safety.
Added preprocessor directive for NET framework support.
Updated using directives to include repository and EF Core
namespaces. Adjusted code structure for improved compatibility.
Updated `DigitalData.Core.Infrastructure.csproj` to include .NET Framework version 4.6.2 alongside net7.0, net8.0, and net9.0. Configured framework-specific settings for nullable reference types, implicit usings, and language versions. Added a new `<ItemGroup>` for net462 to reference `Microsoft.EntityFrameworkCore` version 3.1.32.
- Updated Where() to use AsNoTracking() for read-only queries
- Added GetAll() and GetAllAsync() to retrieve all entities
- Improved repository methods for efficient read operations
- Updated DbRepository constructor to use DbSetFactory<TDbContext, TEntity>
instead of a Func<TDbContext, DbSet<TEntity>> queryFactory.
- Adjusted namespace imports to include DigitalData.Core.Infrastructure.Factory.
- Improved repository instantiation consistency and encapsulation.
- Added `RegisterAllServices` method to centralize service registration
- Introduced `RegsDbSetFactory` queue for custom DbSetFactory registrations
- Extended `RegisterEntity` to support optional DbSetFactory
- Added `RegisterDbSetFactory` for explicit DbSetFactory registration
- Registered `IRepositoryFactory` with `DbRepositoryFactory` in DI
- Introduced AddDbSetFactory to support DbSet factory registration for entities.
- Updated RepositoryConfiguration.RegisterFromAssembly to register both repositories and DbSet factories.
- Changed RegisterFromAssembly and RegisterEntity to void methods instead of fluent interface.
- Extracted DbRepositoryFactory into its own Factory namespace for better separation of concerns.
- Replaced `AddDbRepository<TDbContext, TEntity>` with `AddDbRepository(Action<RepositoryConfiguration>)` for more flexible DI registration.
- Added `RepositoryConfiguration` class to support:
- Registering repositories from an assembly (`RegisterFromAssembly`)
- Registering individual entities (`RegisterEntity`)
- Queues (`RegsFromAssembly` and `RegsEntity`) are used to defer registration until `InvokeAll` is called.
- Allows overriding and scanning multiple entities dynamically instead of static generic method.
- Renamed `Read()` to `Where()` and `ReadOnly()` to `Get()` for clarity.
- Marked old `Read()` and `ReadOnly()` methods as `[Obsolete]` with guidance to use the new methods.
- Updated XML region to separate obsolete methods for better maintainability.
Changed UpdateAsync and DeleteAsync to accept Func<IQueryable<TEntity>, IQueryable<TEntity>> instead of IQueryable<TEntity>
Improved flexibility by allowing callers to compose queries dynamically
Updated overloads to wrap expressions with q => q.Where(expression) for compatibility