LunchPail 2.1.1

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

// Install LunchPail as a Cake Tool
#tool nuget:?package=LunchPail&version=2.1.1


LunchPail is a .NET Standard compliant Unit of Work implementation for ADO.NET. The UoW is the workhorse of the data context, so the project was dubbed "lunch pail" as a reference to blue collar athletes.

NuGet Version Build Status

Getting Started

  1. Register the context within your IoC container (.NET Core shown below using SQL Server):
public void ConfigureServices(IServiceCollection services)
  //rest of code...

  services.AddTransient<IDbConnectionFactory>(options =>
    var builder = new SqlConnectionStringBuilder(Configuration.GetConnectionString("DefaultConnection"));

    return new DbConnectionFactory(() =>
      var conn = new SqlConnection(builder.ConnectionString);

      return conn;
  services.AddScoped<IDbContext, DbContext>();

  //repositories (we'll add this later)
  1. Create a domain class to represents your database object.
public class Product
  public int Id { get; set; }
  public string Name { get; set; }
  1. Create a repository with a dependency on IDbContext
public interface IProductRepository
  Task<Product> Read (int id);

public class ProductRepository : DbRepository
  public ProductRepository(IDbContext dbContext) : base(dbContext) { }

  public Product Read(int id)
    return Connection.QuerySingleOrDefault<Product>("select * from dbo.Product where Id = @id", new { id }, transaction: Transaction);
  1. Register the repository with your IoC container (.NET Core shown below):
public void ConfigureServices(IServiceCollection services)
  services.AddScoped<IProductRepository, ProductRepository>();
  1. With the context and repository registered, you're free to inject this into your controller or service layer.

Note the invocation of dbContext.Commit() which must occur after every interaction is complete to ensure proper disposal of the connection. This is true whether the interaction is a read or write.

public class ProductService
  private readonly IDbContext dbContext;
  private readonly IProductRepository productRepository;

  public ProductService (
    IDbContext dbContext,
    IProductRepository productRepository)
    this.dbContext = dbContext;
    this.productRepository = productRepository;

  public Product Read(int id)
    var product = productRepository.Read(id);
    dbContext.Commit(); // You MUST call commit after all interactions

    return product;

Built with ♥ by Pim Brouwers in Toronto, ON.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on LunchPail:

Package Downloads

A .NET Standard compliant abstract repository for use with LunchPail.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.1 1,475 12/15/2022
2.1.0 4,354 11/27/2020
2.0.0 6,273 11/14/2020
1.0.1 4,541 7/27/2018
1.0.0 811 7/26/2018