All Projects → pimbrouwers → LunchPail

pimbrouwers / LunchPail

Licence: GPL-3.0 License
.NET Standard compliant Unit of Work implementation for ADO.NET

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to LunchPail

Happysocialmedia
Microservices Social Media / Network / Chatt, with .net core 2.2, Docker, Implement with Domain Driven Design with all best practices design and architetural patterns as DDD, CrossCutting IoC, SOLID, etc
Stars: ✭ 28 (+0%)
Mutual labels:  ioc-container, repository-pattern
Simplify
Simplify is a set of .NET libraries that provide infrastructure for your applications. DI and mocking friendly.
Stars: ✭ 52 (+85.71%)
Mutual labels:  ioc-container, repository-pattern
Asmin
Asmin is .NET CORE project infrastructure, to get a quick start on the project.
Stars: ✭ 89 (+217.86%)
Mutual labels:  repository-pattern, unit-of-work
ThunderboltIoc
One of the very first IoC frameworks for .Net that has no reflection. An IoC that casts its services before thunder casts its bolts.
Stars: ✭ 40 (+42.86%)
Mutual labels:  ioc-container
BetterRepository
Better Enhanced Repository Pattern Implementation in .NET C#
Stars: ✭ 27 (-3.57%)
Mutual labels:  repository-pattern
devonfw4flutter-mts-app
Large-Scale Flutter Reference Application. An Extension of DevonFw's My Thai Star Project
Stars: ✭ 54 (+92.86%)
Mutual labels:  repository-pattern
Kodkod
https://github.com/alirizaadiyahsi/Nucleus Web API layered architecture startup template with ASP.NET Core 2.1, EF Core 2.1 and Vue Client
Stars: ✭ 45 (+60.71%)
Mutual labels:  repository-pattern
AzureFunctions.Extensions
This provides some useful extensions for Azure Functions.
Stars: ✭ 81 (+189.29%)
Mutual labels:  ioc-container
Football-App
⚽ Football App using MVVM, LiveData, RxJava2, DI, Room, Repository Patern
Stars: ✭ 17 (-39.29%)
Mutual labels:  repository-pattern
NYTimesMostPopularArticles
A simple app to hit the NY Times Most Popular Articles API and show a list of articles, that shows details when items on the list are tapped (a typical master/detail app), also user able to browse/ add articles to favorite list that implements MVVM architecture using Dagger2, Retrofit, Coroutines, LiveData, RoomDatabase, Database Debugging, Data…
Stars: ✭ 38 (+35.71%)
Mutual labels:  repository-pattern
jpa-repository
Repository programming model with JPA 2 and Specification pattern provides a simple and easy way to build the data access layer.
Stars: ✭ 14 (-50%)
Mutual labels:  repository-pattern
Github-Trending-Repos
An Android App that lists the most trending repositories from Github.
Stars: ✭ 57 (+103.57%)
Mutual labels:  repository-pattern
Oragon.Spring
Spring.NET (spring.core + spring.aop) on .NET Standard 2.0
Stars: ✭ 19 (-32.14%)
Mutual labels:  ioc-container
laravel-repository
Repository pattern implementation for Laravel
Stars: ✭ 49 (+75%)
Mutual labels:  repository-pattern
CSEDevOps
Azure DevOps extensions from CSE DevOps team
Stars: ✭ 18 (-35.71%)
Mutual labels:  ado
Odapter
C# code generator for Oracle packages
Stars: ✭ 16 (-42.86%)
Mutual labels:  ado-net
ECommerceProjectWithWebAPI
.NET 5.0 Web API İle E-Ticaret Sitesi Yapımı MVC,Win Form,Angular ve Mobil
Stars: ✭ 35 (+25%)
Mutual labels:  repository-pattern
alpha-dic
Powerful dependency injection container for node.js
Stars: ✭ 27 (-3.57%)
Mutual labels:  ioc-container
MediatR.Extensions.Autofac.DependencyInjection
Autofac plug-in for MediatR.
Stars: ✭ 30 (+7.14%)
Mutual labels:  ioc-container
mvp-android-template
MVP Android Template to give you a Quick Head Start for your next Android Project. It implements MVP Architecture using Dagger2, Room, RxJava2 , Retrofit2
Stars: ✭ 20 (-28.57%)
Mutual labels:  repository-pattern

LunchPail

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):
//startup.cs
public void ConfigureServices(IServiceCollection services)
{
  //rest of code...
  
  //context
  services.AddTransient<IDbConnectionFactory>(options =>
  {
    var builder = new SqlConnectionStringBuilder(Configuration.GetConnectionString("DefaultConnection"));

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

      conn.Open();
      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):
//startup.cs
public void ConfigureServices(IServiceCollection services)
{
  //repositories
  services.AddScoped<IProductRepository, ProductRepository>();
}
  1. With the context and repository registered, you're free to inject this into your controller or service layer.
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();

    return product;
  }
}

Built with by Pim Brouwers in Toronto, ON.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].