BeireMKit.Data 1.0.7

dotnet add package BeireMKit.Data --version 1.0.7
                    
NuGet\Install-Package BeireMKit.Data -Version 1.0.7
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BeireMKit.Data" Version="1.0.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BeireMKit.Data" Version="1.0.7" />
                    
Directory.Packages.props
<PackageReference Include="BeireMKit.Data" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BeireMKit.Data --version 1.0.7
                    
#r "nuget: BeireMKit.Data, 1.0.7"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BeireMKit.Data@1.0.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BeireMKit.Data&version=1.0.7
                    
Install as a Cake Addin
#tool nuget:?package=BeireMKit.Data&version=1.0.7
                    
Install as a Cake Tool

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

  1. manipulate data from the database in a simplified way.
  2. Perform queries.
  3. 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();
      }
      
  • 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();
      }
      
  • 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last Updated
1.0.7 240 6/19/2024
1.0.6 166 6/11/2024
1.0.5 183 6/11/2024
1.0.4 173 6/10/2024
1.0.3 223 5/30/2024
1.0.2 199 5/16/2024
1.0.1 323 5/14/2024