All Projects → nreco → Data

nreco / Data

Licence: mit
Fast DB-independent DAL for .NET Core: abstract queries, SQL commands builder, schema-less data access, POCO mapping (micro-ORM).

Programming Languages

csharp
926 projects

Projects that are alternatives of or similar to Data

Simple Crud
PHP library to provide magic CRUD in MySQL/Sqlite databases with zero configuration
Stars: ✭ 190 (+26.67%)
Mutual labels:  orm, database, crud
Chloe
A lightweight and high-performance Object/Relational Mapping(ORM) library for .NET --C#
Stars: ✭ 1,248 (+732%)
Mutual labels:  orm, poco, dotnetcore
Evolutility Server Node
Model-driven REST or GraphQL backend for CRUD and more, written in Javascript, using Node.js, Express, and PostgreSQL.
Stars: ✭ 84 (-44%)
Mutual labels:  orm, database, crud
Lealone
极具创新的面向微服务和 OLTP/OLAP 场景的单机与分布式关系数据库
Stars: ✭ 1,802 (+1101.33%)
Mutual labels:  orm, database
Servicestack.ormlite
Fast, Simple, Typed ORM for .NET
Stars: ✭ 1,532 (+921.33%)
Mutual labels:  orm, poco
Efcore
EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
Stars: ✭ 10,838 (+7125.33%)
Mutual labels:  orm, database
Borm
【🔥今日热门】🏎️ 更好的ORM库 (Better ORM library that is simple, fast and self-mockable for Go)
Stars: ✭ 102 (-32%)
Mutual labels:  orm, crud
Roomasset
A helper library to help using Room with existing pre-populated database [DEPRECATED].
Stars: ✭ 138 (-8%)
Mutual labels:  orm, database
Sandman2
Automatically generate a RESTful API service for your legacy database. No code required!
Stars: ✭ 1,765 (+1076.67%)
Mutual labels:  orm, database
Netbarcode
Barcode generation library written in C# and .NET Standard 2
Stars: ✭ 149 (-0.67%)
Mutual labels:  dotnetcore, dot-net
Owasp Mth3l3m3nt Framework
OWASP Mth3l3m3nt Framework is a penetration testing aiding tool and exploitation framework. It fosters a principle of attack the web using the web as well as pentest on the go through its responsive interface.
Stars: ✭ 139 (-7.33%)
Mutual labels:  database, crud
Tornado Sqlalchemy
SQLAlchemy support for Tornado
Stars: ✭ 112 (-25.33%)
Mutual labels:  orm, database
Ship Hold
data access framework for Postgresql on nodejs
Stars: ✭ 110 (-26.67%)
Mutual labels:  orm, database
Nsubstitute
A friendly substitute for .NET mocking libraries.
Stars: ✭ 1,646 (+997.33%)
Mutual labels:  dotnetcore, dot-net
Reactiveandroid
🚀 Simple and powerful ORM for Android
Stars: ✭ 102 (-32%)
Mutual labels:  orm, database
Typeorm Plus
TypeORM+ adds functionality to TypeORM intending to make the Repository and QueryBuilder more powerful.
Stars: ✭ 135 (-10%)
Mutual labels:  orm, database
Entityframeworkcore.cacheable
EntityFrameworkCore second level cache
Stars: ✭ 138 (-8%)
Mutual labels:  orm, database
Vaadin On Kotlin
Writing full-stack statically-typed web apps on JVM at its simplest
Stars: ✭ 141 (-6%)
Mutual labels:  database, crud
Sequelize Ui
Browser-based GUI for previewing and generating Sequelize project files.
Stars: ✭ 142 (-5.33%)
Mutual labels:  orm, database
Node Mysql Utilities
Query builder for node-mysql with introspection, etc.
Stars: ✭ 98 (-34.67%)
Mutual labels:  database, crud

NReco.Data

Lightweight high-performance data access components for generating SQL commands, mapping results to strongly typed POCO models or dictionaries, schema-less CRUD-operations with RecordSet.

NuGet Windows x64 Ubuntu 14.04
NuGet Release AppVeyor Travis CI
  • very fast: NReco.Data shows almost the same performance as Dapper but offers more features
  • abstract DB-independent Query structure: no need to compose raw SQL in the code + query can be constructed dynamically (at run-time)
  • automated CRUD commands generation
  • generate several SQL statements into one IDbCommand (batch inserts, updates, selects for multiple recordsets: DbBatchCommandBuilder)
  • supports mapping to annotated POCO models (EF Core entity models), allows customized mapping of query result
  • API for schema-less data access (dictionaries, RecordSet, DataTable)
  • can handle results returned by stored procedure, including multiple record sets
  • application-level data views (for complex SQL queries) that accessed like simple read-only tables (DbDataView)
  • parser for compact string query representation: relex expressions
  • can be used with any existing ADO.NET data provider (SQL Server, PostgreSql, Sqlite, MySql, Oracle etc)
  • supports .NET Framework 4.5+, .NET Core 2.x / 3.x (netstandard2.0)

Quick reference

Class Dependencies Purpose
DbFactory incapsulates DB-specific functions and conventions
DbCommandBuilder IDbFactory composes IDbCommand and SQL text for SELECT/UPDATE/DELETE/INSERT, handles app-level dataviews
DbDataAdapter IDbCommandBuilder, IDbConnection CRUD operations for model, dictionary, DataTable or RecordSet: Insert/Update/Delete/Select. Async versions are supported for all methods.
Query Represents abstract query to database; used as parameter in DbCommandBuilder, DbDataAdapter
RelexParser Parsers query string expression (Relex) into Query structure
RecordSet RecordSet model represents in-memory data records, this is lightweight and efficient replacement for classic DataTable/DataRow
DataReaderResult IDataReader reads data from any data reader implementation and efficiently maps it to models, dictionaries, DataTable or RecordSet

NReco.Data documentation:

How to use

Generic implementation of DbFactory can be used with any ADO.NET connector.

DbFactory initialization for SqlClient:

var dbFactory = new DbFactory(System.Data.SqlClient.SqlClientFactory.Instance) {
	LastInsertIdSelectText = "SELECT @@IDENTITY" };

DbFactory initialization for Mysql:

var dbFactory = new DbFactory(MySql.Data.MySqlClient.MySqlClientFactory.Instance) {
	LastInsertIdSelectText = "SELECT LAST_INSERT_ID()" };

DbFactory initialization for Postgresql:

var dbFactory = new DbFactory(Npgsql.NpgsqlFactory.Instance) {
	LastInsertIdSelectText = "SELECT lastval()" };

DbFactory initialization for Sqlite:

var dbFactory = new DbFactory(Microsoft.Data.Sqlite.SqliteFactory.Instance) {
	LastInsertIdSelectText = "SELECT last_insert_rowid()" };

DbCommandBuilder generates SQL commands by Query:

var dbCmdBuilder = new DbCommandBuilder(dbFactory);
var selectCmd = dbCmdBuilder.GetSelectCommand( 
	new Query("Employees", (QField)"BirthDate" > new QConst(new DateTime(1960,1,1)) ) );
var selectGroupByCmd = dbCmdBuilder.GetSelectCommand( 
	new Query("Employees").Select("company_id", new QAggregateField("avg_age", "AVG", "age") ) );
var insertCmd = dbCmdBuilder.GetInsertCommand(
	"Employees", new { Name = "John Smith", BirthDate = new DateTime(1980,1,1) } );
var deleteCmd = dbCmdBuilder.GetDeleteCommand(
	new Query("Employees", (QField)"Name" == (QConst)"John Smith" ) );

DbDataAdapter - provides simple API for CRUD-operations:

var dbConnection = dbFactory.CreateConnection();
dbConnection.ConnectionString = "<db_connection_string>";
var dbAdapter = new DbDataAdapter(dbConnection, dbCmdBuilder);
// map select results to POCO models
var employeeModelsList = dbAdapter.Select( new Query("Employees") ).ToList<Employee>();
// read select result to dictionary
var employeeDictionary = dbAdapter.Select( 
    new Query("Employees", (QField)"EmployeeID"==(QConst)newEmployee.EmployeeID ).Select("FirstName","LastName") 
  ).ToDictionary();
// update by dictionary
dbAdapter.Update( 
	new Query("Employees", (QField)"EmployeeID"==(QConst)1001 ),
	new Dictionary<string,object>() {
		{"FirstName", "Bruce" },
		{"LastName", "Wayne" }
	});
// insert by model
dbAdapter.Insert( "Employees", new { FirstName = "John", LastName = "Smith" } );  

RecordSet - efficient replacement for DataTable/DataRow with very similar API:

var rs = dbAdapter.Select(new Query("Employees")).ToRecordSet();
rs.SetPrimaryKey("EmployeeID");
foreach (var row in rs) {
	Console.WriteLine("ID={0}", row["EmployeeID"]);
	if ("Canada".Equals(row["Country"]))
		row.Delete();
}
dbAdapter.Update(rs);
var rsReader = new RecordSetReader(rs); // DbDataReader for in-memory rows

Relex - compact relational query expressions:

var relex = @"Employees(BirthDate>""1960-01-01"":datetime)[Name,BirthDate]"
var relexParser = new NReco.Data.Relex.RelexParser();
Query q = relexParser.Parse(relex);

More examples

  • Command Builder: illustrates SQL commands generation, command batching (inserts)
  • Data Adapter: CRUD operations with dictionaries, POCO, RecordSet
  • DataSet GenericDataAdapter: how to implement generic DataSet DataAdapter (Fill/Update) for any ADO.NET provider
  • SQL logging: how to extend DbFactory and add wrapper for DbCommand that logs SQL commands produced by DbDataAdapter
  • DB WebApi: configures NReco.Data services in MVC Core app, simple REST API for database tables
  • MVC Core CRUD: full-functional CRUD (list, add/edit forms) that uses NReco.Data as data layer in combination with EF Core
  • DB Metadata: extract database metadata (list of tables, columns) with information_schema queries
  • GraphQL API for SQL database: provides simple GraphQL API by existing database schema (simple queries only, no mutations yet)

Who is using this?

NReco.Data is in production use at SeekTable.com and PivotData microservice.

License

Copyright 2016-2020 Vitaliy Fedorchenko and contributors

Distributed under the MIT license

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].