/lazorm

LAZy people's OR Mapper

Primary LanguageC#

lazorm

LAZy people's OR Mapper

What is lazorm?

Lazorm is a super simple OR mapper library for .Net Core.

one minute demo(youtube link)

Watch the video

Overview

Lazorm has a two sides, one is a code generator, ahother is a runtime to let generated codes work.

Key functions

  1. Entity Class generator from database

lazorm provides a command line tool which create class files
with full of table columns as properties.

Available database products are following:

  • SQL Server
  • Oracle
  • MySQL
  • SQLite

The generated code holds your connectionstring in appsettings.json. So you feel easy to run entity codes.

  1. Rich functions on coding

They also have full of crud functions as default. So all you have to do is call Get method and you will have your data brought. You can also specify your sql to get/modify your data.

  1. Source code provision

You can get all crud functions as source code generated into parcial class. So if you think it's not your cup of tea, you can write your own methods into another half of parcial class.

Isn't it a zero-risk approach to give a try?

Installation

** Important **

lazorm has two part of library:

  1. code generator (as a .Net Core tool - also a.k.a. tool-path tool)
  2. library (as a nuget package)

1. Installing code generator

Global install tool by typing(RECOMMENDED):

dotnet tool install -g lazorm

Or local install tool on your project if you like:

dotnet new tool-manifest
dotnet tool install lazorm

Then you go 2 things respectively on your project:

2. Generating OR Mapper code

echo "creating entity files into Entities/AutoGenerated dir"
dotnet lazorm -k mssql -c "your connectionstring here" -m

3. Installing runtime into your project(then it runs properly)

echo "installing library that entities depends"
dotnet add package lazorm

Tutorial

You make a project by typing

dotnet new console -n LazormTest
cd LazormTest

Then create entity from database

echo "creating entity files into Entities/AutoGenerated dir"
dotnet lazorm -k mssql -c "your connectionstring here"

echo "installing library that entities depends"
dotnet add package lazorm

That's it! You will see entity files in Entities directory.

Don't forget to install package lazormlib. Because entity files do need it to work with.

In your program.cs file, you modify Main method

// entitiy class name is for example.
var countries = Lazorm.Country.Get(ID: 1);
foreach(var country in countries)
{
    Console.WriteLine("Name: {0}", country.Name);
}

You run project with F5, That's it! You will see the name of countries there.

Object.Get and Object.SaveChanges are essentials of this framework. NO MANAGERS! Because our entities can do everything by their own.

"Mom, don't change my clothes! I can do it with my own!"

Database first oriented

We know code first is a good approach but this product is oriented database first.

Reason: It gets simpler with DB first approach - because no migration table polution nore annoying migration failure.