ShadowSql is split into a simplified version and an easy-to-use version, and the project and nuget package are split simultaneously
ShadowSql project split into ShadowSql
The project is split into and
rely
Relying on ShadowSql
The goal of the streamlined version is to be sufficient, direct, and interface-based programming
The goal of the Easy-to-use version is easy to use, and is based on generic programming.
Easy-to-use version depends on the simplified version, which is extended to the simplified version.
Here are a few examples to compare
1. Example of reading a table
1. The simplified version code is as follows:
var table = ("Students"); var count = (Executor);var select = new TableSelect(table); var students = select.Get<Student>(Executor);
2. The easy-to-use version code is as follows:
var select = ("Students") .ToDapperSelect(); var count = select.Count();var students = select.Get<Student>();
In "ShadowSql: Create High-Performance ORM and Variety Magic with Dapper", there are three ways to execute Dapper
Only one of the simplified versions is supported, and all three are supported by the easy-to-use versions.
2. Examples of pagination query data
1. The simplified version code is as follows:
var table = new StudentTable("Students"); var query = new TableSqlQuery(table) .Where((9)); var count = (Executor);var cursor = new TableCursor(query) .Desc() .Skip(1) .Take(10); var select = new TableSelect(cursor); var students = select.Get<Student>(Executor);
2. The easy-to-use version code is as follows:
var query = new StudentTable("Students") .ToSqlQuery() .Where(table => (9)); var count = (Executor);var students = () .Desc(table => ) .Skip(1) .Take(10) .ToSelect() .Get<Student>(Executor);
The difference between the two is more obvious in the pagination query example. If you do not ask for count in the easy-to-use version, the entire process can be written in a continuous manner, which is very coherent.
Lite version basics need to define a variable for each component
In addition to connecting various components through navigation properties (extension method), the Easy-to-Use version also provides higher-order functions (function type parameters for call within the main function) to perform personalized queries.
Of course, the easy-to-use version will add a little CPU and memory overhead when using generics, which can be ignored
In addition, this example also reflects the major difference between the design ideas of this tool and SqlKata
SqlKata's Query is a large object that includes all possible components;
ShadowSql is assigned on demand, and only links required components when needed.
This is also one of the reasons why SqlKata executes slower than ShadowSql and consumes more memory than ShadowSql
The streamlined version and the easy-to-use version have their own advantages and disadvantages. Carrots and cabbage have their own preferences, and I like both of them.
If you write widgets, you prefer easy-to-use version. It is very suitable if you do microservices streamlined version.