![]() |
VOOZH | about |
dotnet add package Indiko.Blocks.DataAccess.Abstractions --version 2.8.0
NuGet\Install-Package Indiko.Blocks.DataAccess.Abstractions -Version 2.8.0
<PackageReference Include="Indiko.Blocks.DataAccess.Abstractions" Version="2.8.0" />
<PackageVersion Include="Indiko.Blocks.DataAccess.Abstractions" Version="2.8.0" />Directory.Packages.props
<PackageReference Include="Indiko.Blocks.DataAccess.Abstractions" />Project file
paket add Indiko.Blocks.DataAccess.Abstractions --version 2.8.0
#r "nuget: Indiko.Blocks.DataAccess.Abstractions, 2.8.0"
#:package Indiko.Blocks.DataAccess.Abstractions@2.8.0
#addin nuget:?package=Indiko.Blocks.DataAccess.Abstractions&version=2.8.0Install as a Cake Addin
#tool nuget:?package=Indiko.Blocks.DataAccess.Abstractions&version=2.8.0Install as a Cake Tool
Core abstractions for data access layer implementation in the Indiko framework, providing interfaces and base classes for repositories, unit of work, and database context management.
This package defines the fundamental contracts for implementing data access layers across different ORM providers (Entity Framework, MongoDB, Marten, etc.). It provides a consistent API for CRUD operations, querying, and transaction management.
dotnet add package Indiko.Blocks.DataAccess.Abstractions
Comprehensive repository interface with over 50 methods for data operations.
public interface IRepository<TEntity, TIdType> where TEntity : class, IEntity<TIdType>
{
// CRUD Operations
ValueTask<bool> AddAsync(TEntity entity, CancellationToken cancellationToken = default);
ValueTask<bool> UpdateAsync(TEntity entity, CancellationToken cancellationToken = default);
ValueTask<bool> DeleteAsync(TEntity entity, bool useSoftDelete = true, CancellationToken cancellationToken = default);
// Read Operations
ValueTask<TEntity> ReadByIdAsync(TIdType id, CancellationToken cancellationToken = default);
ValueTask<IEnumerable<TEntity>> ReadAllAsync(bool asNotracking = true, CancellationToken cancellationToken = default);
ValueTask<IEnumerable<TEntity>> ReadManyByQueryAsync(Expression<Func<TEntity, bool>> where, ...);
ValueTask<PagedList<TEntity>> ReadManyByQueryPagedAsync(Expression<Func<TEntity, bool>> where, int page = 1, int pageSize = 25, ...);
// Aggregations
ValueTask<int> CountAsync(Expression<Func<TEntity, bool>> where, ...);
ValueTask<decimal> SumAsync(Expression<Func<TEntity, decimal>> where, ...);
ValueTask<TResult> MaxAsync<TResult>(Expression<Func<TEntity, TResult>> where, ...);
ValueTask<TResult> MinAsync<TResult>(Expression<Func<TEntity, TResult>> where, ...);
ValueTask<double> AverageAsync(Expression<Func<TEntity, bool>> where, Expression<Func<TEntity, double>> averageBy, ...);
// Advanced Queries
ValueTask<IEnumerable<TResult>> GroupByAsync<TKey, TResult>(...);
ValueTask<IEnumerable<TProperty>> DistinctAsync<TProperty>(...);
ValueTask<bool> ExistsAsync(Expression<Func<TEntity, bool>> where, ...);
// Batch Operations
ValueTask<bool> AddRangeAsync(IEnumerable<TEntity> entities, ...);
ValueTask<bool> UpdateRangeAsync(IEnumerable<TEntity> entities, ...);
ValueTask<bool> DeleteRangeAsync(IEnumerable<TEntity> entities, ...);
}
Transaction management interface.
public interface IUnitOfWork : IDisposable
{
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
Task BeginTransactionAsync(CancellationToken cancellationToken = default);
Task CommitTransactionAsync(CancellationToken cancellationToken = default);
Task RollbackTransactionAsync(CancellationToken cancellationToken = default);
}
Service locator for accessing repositories.
public interface IManager
{
IRepository<TEntity, TIdType> GetRepository<TEntity, TIdType>()
where TEntity : class, IEntity<TIdType>;
}
Marker interface for data access blocks.
public interface IDataAccessBlock : IBlock
{
}
public class UserService
{
private readonly IRepository<User, Guid> _userRepository;
private readonly IUnitOfWork _unitOfWork;
public UserService(IRepository<User, Guid> userRepository, IUnitOfWork unitOfWork)
{
_userRepository = userRepository;
_unitOfWork = unitOfWork;
}
// Create
public async Task<User> CreateUserAsync(User user)
{
await _userRepository.AddAsync(user);
await _unitOfWork.SaveChangesAsync();
return user;
}
// Read
public async Task<User> GetUserAsync(Guid id)
{
return await _userRepository.ReadByIdAsync(id);
}
// Update
public async Task UpdateUserAsync(User user)
{
await _userRepository.UpdateAsync(user);
await _unitOfWork.SaveChangesAsync();
}
// Delete (soft delete)
public async Task DeleteUserAsync(Guid id)
{
await _userRepository.DeleteAsync(id, useSoftDelete: true);
await _unitOfWork.SaveChangesAsync();
}
}
// Simple query
var activeUsers = await _userRepository.ReadManyByQueryAsync(u => u.IsActive);
// Query with ordering
var recentUsers = await _userRepository.ReadManyByQueryAsync(
where: u => u.IsActive,
orderBy: u => u.CreatedAt,
orderByAscending: false
);
// Paged query
var pagedUsers = await _userRepository.ReadManyByQueryPagedAsync(
where: u => u.IsActive && u.Email.Contains("@example.com"),
page: 1,
pageSize: 20
);
// Query with includes (navigation properties)
var usersWithOrders = await _userRepository.ReadManyByQueryWithIncludesAsync(
where: u => u.IsActive,
asNotracking: true,
includes: "Orders", "Orders.Items"
);
// Query with projection
var userNames = await _userRepository.ReadByQueryWithSelectorAsync(
where: u => u.IsActive,
selector: u => new { u.Id, u.Name, u.Email }
);
// Count
int activeCount = await _userRepository.CountAsync(u => u.IsActive);
// Sum
decimal totalRevenue = await _userRepository.SumAsync(
where: u => u.IsActive,
sumBy: u => u.TotalPurchases
);
// Average
double averageAge = await _userRepository.AverageAsync(
where: u => u.IsActive,
averageBy: u => u.Age
);
// Min/Max
var oldestUser = await _userRepository.MaxAsync(u => u.Age);
var youngestUser = await _userRepository.MinAsync(u => u.Age);
// Group By
var usersByCountry = await _userRepository.GroupByAsync(
filter: u => u.IsActive,
groupBy: u => u.Country,
selector: g => new
{
Country = g.Key,
Count = g.Count(),
TotalRevenue = g.Sum(u => u.TotalPurchases)
}
);
// Distinct
var countries = await _userRepository.DistinctAsync(
selector: u => u.Country,
filter: u => u.IsActive
);
// Add multiple entities
var newUsers = new List<User> { user1, user2, user3 };
await _userRepository.AddRangeAsync(newUsers);
await _unitOfWork.SaveChangesAsync();
// Update multiple entities
await _userRepository.UpdateRangeAsync(usersToUpdate);
await _unitOfWork.SaveChangesAsync();
// Delete multiple entities
await _userRepository.DeleteRangeAsync(usersToDelete);
await _unitOfWork.SaveChangesAsync();
public async Task TransferFundsAsync(Guid fromUserId, Guid toUserId, decimal amount)
{
await _unitOfWork.BeginTransactionAsync();
try
{
var fromUser = await _userRepository.ReadByIdAsync(fromUserId);
var toUser = await _userRepository.ReadByIdAsync(toUserId);
fromUser.Balance -= amount;
toUser.Balance += amount;
await _userRepository.UpdateAsync(fromUser);
await _userRepository.UpdateAsync(toUser);
await _unitOfWork.SaveChangesAsync();
await _unitOfWork.CommitTransactionAsync();
}
catch
{
await _unitOfWork.RollbackTransactionAsync();
throw;
}
}
public class OrderService
{
private readonly IManager _manager;
private readonly IUnitOfWork _unitOfWork;
public OrderService(IManager manager, IUnitOfWork unitOfWork)
{
_manager = manager;
_unitOfWork = unitOfWork;
}
public async Task CreateOrderAsync(Order order)
{
var orderRepo = _manager.GetRepository<Order, Guid>();
var userRepo = _manager.GetRepository<User, Guid>();
var user = await userRepo.ReadByIdAsync(order.UserId);
if (user == null) throw new Exception("User not found");
await orderRepo.AddAsync(order);
await _unitOfWork.SaveChangesAsync();
}
}
Abstract base class for repository implementations.
public abstract class BaseRepository<TEntity, TIdType> : IRepository<TEntity, TIdType>
where TEntity : class, IEntity<TIdType>
{
protected abstract IQueryable<TEntity> GetQueryable();
// ... common implementation
}
Abstract base class for database context implementations.
public abstract class BaseDbContext
{
public abstract Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
// ... common implementation
}
Interface for entity configuration.
public interface IEntityConfiguration<TEntity> where TEntity : class
{
void Configure(IEntityBuilder<TEntity> builder);
}
Registry for managing entity configurations.
public class EntityConfigurationRegistry : IEntityConfigurationRegistry
{
public void Register<TEntity>(IEntityConfiguration<TEntity> configuration)
where TEntity : class;
public IEnumerable<IEntityConfiguration<TEntity>> GetConfigurations<TEntity>()
where TEntity : class;
}
public enum DatabaseType
{
SqlServer,
PostgreSQL,
MySQL,
MongoDB,
SQLite,
Oracle,
MariaDB
}
public enum OrmApproach
{
EntityFramework,
Dapper,
MongoDB,
Marten,
NHibernate
}
public class DataAccessOptions
{
public string ConnectionString { get; set; }
public DatabaseType DatabaseType { get; set; }
public OrmApproach OrmApproach { get; set; }
public bool EnableSensitiveDataLogging { get; set; }
public int CommandTimeout { get; set; }
}
Indiko.Common.AbstractionsIndiko.Blocks.Common.AbstractionsSee LICENSE file in the repository root.
Indiko.Blocks.DataAccess.EntityFramework - Entity Framework Core implementationIndiko.Blocks.DataAccess.MongoDb - MongoDB implementationIndiko.Blocks.DataAccess.Marten - Marten (PostgreSQL) implementationIndiko.Blocks.Common.Management - Block management system| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 4 NuGet packages that depend on Indiko.Blocks.DataAccess.Abstractions:
| Package | Downloads |
|---|---|
|
Indiko.Blocks.DataAccess.MongoDb
Building Blocks DataAccess Mongo DB |
|
|
Indiko.Blocks.DataAccess.EntityFramework
Building Blocks DataAccess EntityFramework |
|
|
Indiko.Blocks.DataAccess.Marten
Building Blocks DataAccess Marten |
|
|
Indiko.Blocks.DataAccess.Dapper
Building Blocks DataAccess Dapper — micro-ORM provider using Dapper and SqlKata |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.8.0 | 185 | 5/22/2026 |
| 2.7.8 | 173 | 5/7/2026 |
| 2.7.7 | 136 | 5/7/2026 |
| 2.7.6 | 187 | 4/23/2026 |
| 2.7.5 | 195 | 4/23/2026 |
| 2.7.4 | 137 | 4/23/2026 |
| 2.7.3 | 138 | 4/23/2026 |
| 2.7.2 | 142 | 4/23/2026 |
| 2.7.1 | 139 | 4/23/2026 |
| 2.7.0 | 144 | 4/23/2026 |
| 2.6.4 | 175 | 4/21/2026 |
| 2.6.3 | 138 | 4/21/2026 |
| 2.6.2 | 154 | 4/21/2026 |
| 2.6.1 | 129 | 4/18/2026 |
| 2.6.0 | 121 | 4/17/2026 |
| 2.5.1 | 136 | 4/14/2026 |
| 2.5.0 | 167 | 3/30/2026 |
| 2.2.18 | 144 | 3/8/2026 |
| 2.2.17 | 115 | 3/8/2026 |
| 2.2.16 | 116 | 3/8/2026 |