Description
Lightweight data access components for generating SQL commands by dynamic queries, mapping results to strongly typed POCO models or dictionaries, CRUD operations. - DbCommandBuilder for generating SELECT, INSERT, UPDATE and DELETE commands - DbDataAdapter for CRUD-operations - best for schema-less DB access, dynamic DB queries, user-defined filters, reporting applications - fills the gap between minimalistic .NET Core (corefx) System.Data and EF Core - parser for compact string query representation (relex) - can be used with any existing ADO.NET data provider (MsSql, PostgreSql, Sqlite, MySql etc) - supports both full .NET Framework 4.x and .NET Core (netstandard1.5)
NReco.Data alternatives and similar packages
Based on the "ORM" category.
Alternatively, view NReco.Data alternatives based on common mentions on social networks and blogs.
-
TypeORM
ORM for TypeScript and JavaScript. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms. -
Dapper
Dapper - a simple object mapper for .Net [Moved to: https://github.com/DapperLib/Dapper] -
Entity Framework
EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations. -
SqlSugar
.Net ORM Fastest ORM Simple Easy Sqlite orm Oracle ORM Mysql Orm postgresql ORm SqlServer oRm 达梦 ORM 人大金仓 ORM 神通ORM C# ORM , C# ORM .NET ORM NET5 ORM .NET6 ORM ClickHouse orm QuestDb -
FreeSql
🦄 .NET orm, C# orm, VB.NET orm, Mysql orm, Postgresql orm, SqlServer orm, Oracle orm, Sqlite orm, Firebird orm, 达梦 orm, 人大金仓 orm, 神通 orm, 翰高 orm, 南大通用 orm, 虚谷 orm, 国产 orm, Clickhouse orm, QuestDB orm, MsAccess orm. -
EFCore.BulkExtensions
Entity Framework EF Core efcore Bulk Batch Extensions with BulkCopy in .Net for Insert Update Delete Read (CRUD), Truncate and SaveChanges operations on SQL Server, PostgreSQL, MySQL, SQLite -
Dapper Extensions
Dapper Extensions is a small library that complements Dapper by adding basic CRUD operations (Get, Insert, Update, Delete) for your POCOs. For more advanced querying scenarios, Dapper Extensions provides a predicate system. The goal of this library is to keep your POCOs pure by not requiring any attributes or base class inheritance. -
Entity Framework 6
This is the codebase for Entity Framework 6 (previously maintained at https://entityframework.codeplex.com). Entity Framework Core is maintained at https://github.com/dotnet/efcore. -
Massive
A small, happy, dynamic MicroORM for .NET that will love you forever. -
LINQKit
LINQKit is a free set of extensions for LINQ to SQL and Entity Framework power users. -
NPoco
Simple microORM that maps the results of a query onto a POCO object. Project based on Schotime's branch of PetaPoco -
SmartSql
SmartSql = MyBatis in C# + .NET Core+ Cache(Memory | Redis) + R/W Splitting + PropertyChangedTrack +Dynamic Repository + InvokeSync + Diagnostics -
SQLProvider
A general F# SQL database erasing type provider, supporting LINQ queries, schema exploration, individuals, CRUD operations and much more besides. -
LINQ to Twitter
LINQ Provider for the Twitter API (C# Twitter Library) -
Dapper.FastCRUD
fast & light .NET ORM for strongly typed people -
MongoDB Repository pattern implementation
Repository abstraction layer on top of Official MongoDB C# driver -
MongoDB.Entities
A data access library for MongoDB with an elegant api, LINQ support and built-in entity relationship management -
JsonFlatFileDataStore
Simple JSON flat file data store with support for typed and dynamic data. -
MongoFramework
An "Entity Framework"-like interface for MongoDB -
DbExtensions
Data-access framework with a strong focus on query composition, granularity and code aesthetics. -
Linq.Expression.Optimizer
System.Linq.Expression expressions optimizer. http://thorium.github.io/Linq.Expression.Optimizer -
KonfDB
Configuration as a Service for multi-tenant, cross-platform applications -
MapDataReader
Super fast mapping DataReader to strongly typed object, Using AOT source generator. -
ObjectStore
.Net Or-Mapper working with dynamically implemented abstract Classes -
MongoRiver.NET
A library for writing .NET MongoDB oplog tailers. -
EntityFramework.DatabaseMigrator
EntityFramework.DatabaseMigrator is a WinForms utility to help manage Entity Framework 6.0+ migrations. -
Excel2SqlServer
Library for importing Excel spreadsheets into SQL Server tables
ONLYOFFICE Docs — document collaboration in your environment
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of NReco.Data or a related project?
README
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 |
---|---|---|
- 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:
- Getting started and HowTos
- Full API Reference
- something is still not clear? Feel free to ask a question on StackOverflow
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 forDbCommand
that logs SQL commands produced byDbDataAdapter
- 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-2022 Vitaliy Fedorchenko and contributors
Distributed under the MIT license
*Note that all licence references and agreements mentioned in the NReco.Data README section above
are relevant to that project's source code only.