Jerrycurl

An MVC and Razor-powered ORM for .NET

Set up

easily with our NuGet libraries and tools

>
>
>
>
>
>
dotnet new classlib -o Jerrystore
cd Jerrystore
dotnet add package Jerrycurl
dotnet add package Jerrycurl.Vendors.SqlServer
dotnet tool install --global dotnet-jerry
jerry scaffold -v sqlserver -c "SERVER=.;DATABASE=jerrystore;TRUSTED_CONNECTION=true" -ns "Jerrystore.Database"

Compose

elegant SQL for any database operation with Razor

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
-- Queries/Customers/GetCustomerList.cssql
@result CustomerListView
@model CustomerFilter
@project Customer c
@project CustomerAddress a

SELECT
    @c.Col(m => m.Id)        AS @R.Prop(m => m.CustomerId),
    @c.Col(m => m.Email)     AS @R.Prop(m => m.CustomerEmail),
    @a.Col(m => m.Country)   AS @R.Prop(m => m.CustomerCountry)
FROM
    @c.Tbl()
INNER JOIN
    @a.Tbl() ON @a.Col(m => m.Id) = @c.Col(m => m.AddressId)
WHERE
    @c.Col(m => m.Created) >= @M.Par(m => m.MinAge)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
-- Commands/Customers/ChangeEmail.cssql
@model CustomerChangeEmailModel
@project Customer c
@project CustomerEvent e

UPDATE
    @c.TblName()
SET
    @c.ColName(m => m.Email)             = @M.Par(m => m.NewEmail),
    @c.ColName(m => m.IsEmailValidated)  = 0
WHERE
    @c.ColName(m => m.Id)                = @M.Par(m => m.CustomerId)

INSERT INTO @e.TblName()
          ( @e.ColName(m => m.CustomerId), @e.ColName(m => m.Text)  )
VALUES    ( @M.Par(m => m.CustomerId),     @M.Par(m => m.EventText) )

Design

robust data access based on MVC and CQS principles

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Accessors/CustomersAccessor.cs
namespace Jerrystore.Accessors
{
    public class CustomersAccessor : Accessor
    {
        public async Task<IList<CustomerListView>> GetCustomerListAsync(DateTime minAge)
        {
            var filter = new CustomerFilter()
            {
                MinAge = minAge,
            };

            return await this.QueryAsync<CustomerListView>(model: filter);
        }

        public async Task ChangeEmailAsync(int customerId, string newEmail)
        {
            var model = new CustomerChangeEmailModel()
            {
                CustomerId = customerId,
                NewEmail = newEmail,
                EventText = $"Changed email to '{newEmail}'",
            };
        
            await this.ExecuteAsync(model, o => o.UseTransaction());
        }
    }
}

Pro

features for Visual Studio with IntelliSense and advanced tooling

Available for Visual Studio 2019 and 2017
or a full license from our store