SqlRepo is a .NET library for building SQL statements with Lambda Expressions and mapping results to objects
We are please to announce the release of 3.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.
In this release we have completely re-written the entity mapping feature and extended it to provide full control of how data sets are mapped to entities using EntityMappingProfiles. See Entity Mapping for more information.
Read the documentation on our Wiki
or get started using one of our guides
Getting Started (Static Factory)
NuGet Package Manager
Install-Package SqlRepo.SqlServer
dotnet cli
dotnet add package SqlRepo.SqlServer
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;