Skip to content

fredatgithub/SqlRepo

 
 

Repository files navigation

Build status

SqlRepo

We are please to announce the release of 2.0.0 of SqlRepo, our implementation of the Repository Pattern that allows you to build and execute CRUD SQL statements using Lambda Expressions and strong typing. This release includes significant performance improvements and some bug fixes as well as one breaking change.

Breaking Change!!!

We have bumped the major version number because v2 has removed support for passing connection information to the Go method of Statements. You must now configure a default implementation of IConnectionProvider in your bootstrap code. For details see our updated Getting Started guides or Connection Providers.

Read the documentation on our Wiki

or get started using one of our guides

Getting Started (IoC) Getting Started (Static Factory)

Features

  • Compatible with .NET Standard 2.0 and .NET Framework 4.7
  • Intuitively build SQL statements using C# Lambda Expressions
  • Map SQL query results to plain old CLR objects
  • Low memory footprint and high performance
  • Almost 100% unit test coverage

Installation

NuGet Package Manager

Install-Package SqlRepo.SqlServer

dotnet cli

dotnet add package SqlRepo.SqlServer

Example

public class GettingStarted
{
    private IRepositoryFactory repositoryFactory;

    public GettingStarted(IRepositoryFactory repositoryFactory)
    {
        this.repositoryFactory = repositoryFactory;
    }

    public void DoIt()
    {
         var repository = this.repositoryFactory.Create<ToDo>();
         var results = repository.Query()
         .Select(e => e.Id, e => e.Task, e => e.CreatedDate)
         .Where(e => e.IsCompleted == false)
         .Go();
    }
}

Generates the following SQL statement and maps the results back to the list of ToDo objects.

SELECT [dbo].[ToDo].[Id], [dbo].[ToDo].[Task], [dbo].[ToDo].[CreatedDate]
FROM [dbo].[ToDo]
WHERE [dbo].[ToDo].[IsCompleted] = 0;

About

SqlRepo is a .NET library for building SQL statements with Lambda Expressions and mapping results to objects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%