Skip to content

A Razor-based object-relational mapping engine for .NET.

License

Notifications You must be signed in to change notification settings

mephistoc/jerrycurl

Repository files navigation

Build status License LGPLv3 Gitter chat

Jerrycurl - Razor SQL for .NET

Jerrycurl is a lightweight and highly customizable object-relational mapper with emphasis on writing elegant and performant SQL with Razor and C#.

@result MyShop.Data.Views.Orders.OrderUnsentInvoiceView
@model MyShop.Data.Models.CustomerParams

@project Order o
@project Customer c

SELECT
    @o.Col(m => m.InvoiceNumber)        AS @R.Prop(m => m.InvoiceNumber),
    @o.Col(m => m.Completed)            AS @R.Prop(m => m.InvoiceDate),
    @c.Col(m => m.Email)                AS @R.Prop(m => m.CustomerEmail),
    @c.Col(m => m.Address)              AS @R.Prop(m => m.CustomerAddress)
FROM
    @o.Tbl()
INNER JOIN
    @c.Tbl() ON @c.Col(m => m.Id) = @o.Col(m => m.CustomerId)
WHERE
    @o.Col(m => m.CustomerId) = @M.Par(m => m.CustomerId)
    AND
    @o.Col(m => m.Sent) IS NULL
    AND
    @o.Col(m => m.Completed) IS NOT NULL
ORDER BY
    @o.Col(m => m.Completed) ASC

Features

  • CLI tool to quickly scaffold an object model from your database schema
  • Feature-rich collection of Razor extensions for generating SQL from your object model
  • Highly performant queries with one-to-one, one-to-none, one-to-many, many-to-many and self-join support
  • Robust commands with simple @foreach batch generation
  • Reusable subqueries and subcommands with partials and templates
  • Organized, ASP.NET-like project conventions with MVC
  • Native command-query separation suitable for ACID or BASE operations
  • JSON support with Newtonsoft.Json or System.Text.Json
  • Integration with existing Entity Framework Core projects
  • Modern language features with .NET Standard 2.1 and C# 8
  • ...and more

To learn more about Jerrycurl and how to get started, read our official docs or check our samples repo.

Building from source

Jerrycurl can be built on any OS supported by .NET Core and included in this repository is a script that performs all build related tasks.

Prerequisites

  • .NET Core SDK 3.0
  • .NET Core Runtime 2.1+ / 3.0 (to run tests)
  • PowerShell 5.0+ (PowerShell Core on Linux/macOS)
  • Visual Studio 2019 (16.3+) (optional)
  • Docker (optional - for vendor testing)

Clone and Build

Clone the repository and run our build script from PowerShell.

PS> git clone https://github.com/rwredding/jerrycurl
PS> cd jerrycurl
PS> .\build.ps1 [-NoTest] [-NoPack]

This runs the Restore, Clean, Build, [Test] and [Pack] targets on jerrycurl.sln. Each target can also be run manually in Visual Studio if preferred.

Packaged .nupkgs are placed in /artifacts/packages.

Test

The script above cannot include all tests out of the box, as those testing specific databases often require a live running server. To help you include these in your run, you can use our docker compose script with PowerShell to boot up instances of the required databases.

PS> .\test\tools\boot-dbs.ps1 up sqlserver,mysql,postgres,oracle

Please allow ~30 seconds for the databases to be ready after which you can re-run your tests.

Oracle Database requires that you are logged into Docker and have accepted their terms of service.

If you already have an empty database running that can be used for testing, you can manually specify its connection string in the environment variable JERRY_SQLSERVER_CONN, JERRY_MYSQL_CONN, JERRY_POSTGRES_CONN or JERRY_ORACLE_CONN.

License

Copyright © 2019 AC Dancode

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Legal

By submitting a Pull Request, you disavow any rights or claims to any changes submitted to the Jerrycurl project and assign the copyright of those changes to AC Dancode.

If you cannot or do not want to reassign those rights (your employment contract for your employer may not allow this), you should not submit a PR. Open an issue and someone else can do the work.

This is a legal way of saying "If you submit a PR to us, that code becomes ours". 99.9% of the time that's what you intend anyways; we hope it doesn't scare you away from contributing.

About

A Razor-based object-relational mapping engine for .NET.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages