Dapper.DDD.Repository.DependencyInjection 1.9.1

dotnet add package Dapper.DDD.Repository.DependencyInjection --version 1.9.1                
NuGet\Install-Package Dapper.DDD.Repository.DependencyInjection -Version 1.9.1                
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="Dapper.DDD.Repository.DependencyInjection" Version="1.9.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dapper.DDD.Repository.DependencyInjection --version 1.9.1                
#r "nuget: Dapper.DDD.Repository.DependencyInjection, 1.9.1"                
#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.
// Install Dapper.DDD.Repository.DependencyInjection as a Cake Addin
#addin nuget:?package=Dapper.DDD.Repository.DependencyInjection&version=1.9.1

// Install Dapper.DDD.Repository.DependencyInjection as a Cake Tool
#tool nuget:?package=Dapper.DDD.Repository.DependencyInjection&version=1.9.1                

Dapper.DDD.Repository.DependencyInjection

This package provides support for using Dapper.DDD.Repository with the built-in Dependency Injection in .NET.

Usage

After adding this package, you can use the methods

  • ConfigureDapperRepositoryDefaults
  • AddTableRepository (Multiple overloads available)
  • AddViewRepository (Multiple overloads available)

On an IServiceCollection to inject all the repositories you're going to use.

Typically this will be available in Program.cs, though I suggest moving the actual Dapper configuration to your infrastructure layer, similar to this:

public static IServiceCollection AddInfrastructure(this IServiceCollection services, string connectionString)
{
	return services.ConfigureDapperRepositoryDefaults(config =>
	{
		config.QueryGeneratorFactory = new SqlQueryGeneratorFactory();
		config.ConnectionFactory = new SqlConnectionFactory(connectionString);
		config.DapperInjectionFactory = new DapperInjectionFactory();
		config.Schema = "dbo";
	})
	.AddTableRepository<WeatherForecast, long>(config =>
	{
		config.HasKey(weatherForecast => weatherForecast.Id);
		config.HasIdentity(weatherForecast => weatherForecast.Id);
		config.TableName = "WeatherForecasts";
		config.HasDefault(weatherForecast => weatherForecast.Timestamp);
	})
	.AddTableRepository<WeatherStation, int, IWeatherStationRepository, WeatherStationRepository>(config =>
	{
		config.HasKey(weatherStation => weatherStation.Id);
		config.HasIdentity(weatherStation => weatherStation.Id);
		config.TableName = "WeatherStations";
	})
	.AddViewRepository<WeatherForecastView, IWeatherForecastViewRepository, WeatherForecastViewRepository>(config =>
	{
		config.ViewName = "WeatherForecastView";
	});
}

And then simply calling builder.Services.AddInfrastructure from Program.cs.

Documentation

Auto generated documentation via DocFx is available here: https://steffenskov.github.io/Dapper.DDD.Repository/

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.9.1 1,485 11/28/2024
1.9.0 956 11/20/2024
1.8.1 2,798 5/13/2024
1.8.0 169 1/16/2024
1.3.0 278 3/10/2023
1.2.0 2,389 11/25/2022
1.1.3 1,395 7/23/2022
1.1.2 420 7/13/2022
1.1.1 524 7/10/2022
1.1.0 411 7/10/2022
1.0.1 432 7/9/2022
1.0.0 415 7/9/2022