BeireMKit.Data
1.0.7
dotnet add package BeireMKit.Data --version 1.0.7
NuGet\Install-Package BeireMKit.Data -Version 1.0.7
<PackageReference Include="BeireMKit.Data" Version="1.0.7" />
<PackageVersion Include="BeireMKit.Data" Version="1.0.7" />
<PackageReference Include="BeireMKit.Data" />
paket add BeireMKit.Data --version 1.0.7
#r "nuget: BeireMKit.Data, 1.0.7"
#:package BeireMKit.Data@1.0.7
#addin nuget:?package=BeireMKit.Data&version=1.0.7
#tool nuget:?package=BeireMKit.Data&version=1.0.7
BeireMKit Data
The BeireMKit Data library was developed to facilitate interaction with databases, using the Repository, UnitOfWork and a BaseMap for OnModelCreating standards. This documentation will guide you on how to use the functionalities offered by the library.
Features
- manipulate data from the database in a simplified way.
- Perform queries.
- Control transactions.
Requirements
Make sure you have installed the .NET Core 6 SDK on your machine before you start.
How to use Relational Repository
Add the repository service to Startup
- In the ConfigureServices method of the Startup class, add the repository service using the ConfigureRepository() method:
public void ConfigureServices(IServiceCollection services) { services.ConfigureRepository(); }
- In the ConfigureServices method of the Startup class, add the repository service using the ConfigureRepository() method:
Configuring DbContext
Add IBaseContext to your context: Make sure that your context class (YourContext) implements the IBaseDbContext interface.
public class YourContext : DbContext, IBaseDbContext { protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); builder.ApplyConfiguration(new EntityMap()); } }Add YourMap.
using BeireMKit.Data.Map; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; public class EntityMap : MapBase<Entity> { public override void Configure(EntityTypeBuilder<Entity> builder) { base.Configure(builder); builder.ToTable("TableName"); } }Add dependency injection: In the ConfigureServices method of the Startup class, add the dependency injection for your context:
public void ConfigureServices(IServiceCollection services) { services.AddScoped<IBaseDbContext, YourContext>(); }Usage example
using BeireMKit.Data.Interfaces; using BeireMKit.Domain.BaseModels; using BeireMKit.Domain.Extensions; public class Service : IService { private readonly IUnitOfWork _uow; private readonly IRepository<Entity> _repository; public Service( IUnitOfWork uow, IRepository<Entity> repository, ) { _uow = uow; _repository = repository; } public BaseResult<Entity> Add(Entity entity) { var result = _repository.Add(entity); _uow.Commit(); return BaseResult<Entity>.CreateValidResult(result); } }
How to use Non-relational repository MongoDB
Add the repository service to Startup
- In the ConfigureServices method of the Startup class, add the repository service using the ConfigureRepository() method:
public void ConfigureServices(IServiceCollection services) { var mongoDBSettings = builder.Configuration.GetSection("MongoDBSettings").Get<MongoDBSettings>(); builder.Services.AddSingleton(mongoDBSettings); builder.Services.AddScoped<IBaseMongoDbContext, MongoDBContext>(); builder.Services.ConfigureMongoDbRepository(); }
- In the ConfigureServices method of the Startup class, add the repository service using the ConfigureRepository() method:
Configuring DbContext
Add IBaseContext to your context: Make sure that your context class (YourContext) implements the IBaseDbContext interface.
public class YourContext : DbContext, IBaseDbContext { protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); builder.ApplyConfiguration(new EntityMap()); } }Add YourMap.
using BeireMKit.Data.Map; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; public class EntityMap : MapBase<Entity> { public override void Configure(EntityTypeBuilder<Entity> builder) { base.Configure(builder); builder.ToTable("TableName"); } }Add dependency injection: In the ConfigureServices method of the Startup class, add the dependency injection for your context:
public void ConfigureServices(IServiceCollection services) { services.AddScoped<IBaseDbContext, YourContext>(); }Usage example
using BeireMKit.Data.Interfaces; using BeireMKit.Domain.BaseModels; using BeireMKit.Domain.Extensions; public class Service : IService { private readonly IUnitOfWork _uow; private readonly IRepository<Entity> _repository; public Service( IUnitOfWork uow, IRepository<Entity> repository, ) { _uow = uow; _repository = repository; } public BaseResult<Entity> Add(Entity entity) { var result = _repository.Add(entity); _uow.Commit(); return BaseResult<Entity>.CreateValidResult(result); } }
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- BeireMKit.Domain (>= 1.0.7)
- Microsoft.AspNetCore.Identity.EntityFrameworkCore (>= 6.0.1)
- Microsoft.EntityFrameworkCore (>= 6.0.10)
- Microsoft.EntityFrameworkCore.Relational (>= 6.0.1)
- MongoDB.Driver (>= 2.25.0)
-
net8.0
- BeireMKit.Domain (>= 1.0.7)
- Microsoft.AspNetCore.Identity.EntityFrameworkCore (>= 8.0.6)
- Microsoft.EntityFrameworkCore (>= 8.0.6)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.6)
- MongoDB.Driver (>= 2.25.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on BeireMKit.Data:
| Package | Downloads |
|---|---|
|
BeireMKit.Cache
BeireMKit Cache is a library designed to simplify the use of caching in .NET core applications, supporting both in-memory caching and distributed caching via Redis. |
GitHub repositories
This package is not used by any popular GitHub repositories.