Intwenty.DataClient
3.0.0
dotnet add package Intwenty.DataClient --version 3.0.0
NuGet\Install-Package Intwenty.DataClient -Version 3.0.0
<PackageReference Include="Intwenty.DataClient" Version="3.0.0" />
<PackageVersion Include="Intwenty.DataClient" Version="3.0.0" />
<PackageReference Include="Intwenty.DataClient" />
paket add Intwenty.DataClient --version 3.0.0
#r "nuget: Intwenty.DataClient, 3.0.0"
#:package Intwenty.DataClient@3.0.0
#addin nuget:?package=Intwenty.DataClient&version=3.0.0
#tool nuget:?package=Intwenty.DataClient&version=3.0.0
Intwenty.DataClient
A .net core database client library that includes ORM functions, JSON support and more. Perfect when you need to create or retrieve data and you don't want to work with strongly type objects.
Example:
- bool CreateTable(IIBasicDbTable model)
- int InsertEntity(IIBasicDbTable model, JsonElement data)
- JsonElement GetJsonArray(string tablename)
Description
Intwenty.DataClient is a laser fast database client library with a set of functions for object relational mapping and generating JSON directly from SQL query results.
Implementation
Instead of extending the IDbConnection Intwenty.DataClient works as a generic abstraction layer and wraps around other libraries that implements IDbConnection and IDbCommand. All methods on the IDataClient interface that not explicitly takes an sql statment as parameter (GetEntity<T>, InsertEntity<T> etc) generates sql for all supported databases.
Performance
This is a very fast library but it relies on the DbCommand and the DataReader of the underlying libraries.
Included libraries
- MySqlConnector
- NpgSql
- System.Data.SqlClient
- System.Data.SQLite.Core
Supported Databases
Intwenty.DataClient is built as a wrapper around popular client libraries for MS SQLServer, MariaDb, Sqlite and Postgres. This means that all ORM functions and other functions that generates sql is guranteed to work in all databases.
Example
[DbTablePrimaryKey("Id")]
public class Person {
[AutoIncrement]
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
var client = new Connection(DBMS.MariaDb, "MyConnectionString");
client.Open();
client.CreateTable<Person>();
//Insert some rows
for (int i = 0; i < 5000; i++)
client.InsertEntity(new Person() { FirstName = "Donald", LastName = "Duck" });
//Get a list of person objects
var persons = client.GetEntities<Person>();
//Get a filtered list of person objects
var persons = client.GetEntities<Person>("select * from person where id>@P1", new IIntwentySqlParameter[] {new IntwentySqlParameter("@P1", 1000) });
//Get persons as a json string
var persons = client.GetJSONArry("select * from person");
//Get a json array
JsonElement res = dbclient.GetJsonArray("person");
client.Close();
The IDataClient interface
DBMS Database { get; }
void Open();
Task OpenAsync();
void Close();
Task CloseAsync();
void BeginTransaction();
Task BeginTransactionAsync();
void CommitTransaction();
Task CommitTransactionAsync();
void RollbackTransaction();
Task RollbackTransactionAsync();
void CreateTable<T>();
Task CreateTableAsync<T>();
bool CreateTable(IIBasicDbTable model);
Task<bool> CreateTableAsync(IIBasicDbTable model);
void ModifyTable<T>();
string GetCreateTableSqlStatement<T>();
string GetInsertSqlStatement<T>(T entity);
string GetUpdateSqlStatement<T>(T entity);
string GetCreateTableSqlStatement(IIBasicDbTable model);
string GetInsertSqlStatement(IIBasicDbTable model, JsonElement data);
string GetUpdateSqlStatement(IIBasicDbTable model, JsonElement data);
bool TableExists<T>();
Task<bool> TableExistsAsync<T>();
bool TableExists(string tablename);
Task<bool> TableExistsAsync(string tablename);
bool ColumnExists(string tablename, string columnname);
Task<bool> ColumnExistsAsync(string tablename, string columnname);
void RunCommand(string sql, bool isprocedure=false, IIntwentySqlParameter[] parameters=null);
Task RunCommandAsync(string sql, bool isprocedure = false, IIntwentySqlParameter[] parameters = null);
object GetScalarValue(string sql, bool isprocedure = false, IIntwentySqlParameter[] parameters = null);
Task<object> GetScalarValueAsync(string sql, bool isprocedure = false, IIntwentySqlParameter[] parameters = null);
T GetEntity<T>(string id) where T : new();
Task<T> GetEntityAsync<T>(string id) where T : new();
T GetEntity<T>(int id) where T : new();
Task<T> GetEntityAsync<T>(int id) where T : new();
T GetEntity<T>(string sql, bool isprocedure) where T : new();
Task<T> GetEntityAsync<T>(string sql, bool isprocedure) where T : new();
T GetEntity<T>(string sql, bool isprocedure, IIntwentySqlParameter[] parameters = null) where T : new();
Task<T> GetEntityAsync<T>(string sql, bool isprocedure, IIntwentySqlParameter[] parameters = null) where T : new();
JsonElement GetEntity(IIBasicDbTable model, string id);
Task<JsonElement> GetEntityAsync(IIBasicDbTable model, string id);
JsonElement GetEntity(IIBasicDbTable model, int id);
Task<JsonElement> GetEntityAsync(IIBasicDbTable model, int id);
JsonElement GetEntity(string sql, bool isprocedure);
Task<JsonElement> GetEntityAsync(string sql, bool isprocedure);
JsonElement GetEntity(string sql, bool isprocedure, IIntwentySqlParameter[] parameters = null);
Task<JsonElement> GetEntityAsync(string sql, bool isprocedure, IIntwentySqlParameter[] parameters = null);
List<T> GetEntities<T>() where T : new();
Task<List<T>> GetEntitiesAsync<T>() where T : new();
List<T> GetEntities<T>(string sql, bool isprocedure=false) where T : new();
Task<List<T>> GetEntitiesAsync<T>(string sql, bool isprocedure = false) where T : new();
List<T> GetEntities<T>(string sql, bool isprocedure, IIntwentySqlParameter[] parameters=null) where T : new();
Task<List<T>> GetEntitiesAsync<T>(string sql, bool isprocedure, IIntwentySqlParameter[] parameters = null) where T : new();
JsonElement GetJsonArray(string sql, bool isprocedure, IIntwentySqlParameter[] parameters = null);
JsonElement GetJsonArray(string tablename);
Task<JsonElement> GetJsonArrayAsync(string sql, bool isprocedure, IIntwentySqlParameter[] parameters = null);
Task<JsonElement> GetJsonArrayAsync(string tablename);
IResultSet GetResultSet(string sql, bool isprocedure = false, IIntwentySqlParameter[] parameters = null);
Task<IResultSet> GetResultSetAsync(string sql, bool isprocedure = false, IIntwentySqlParameter[] parameters = null);
DataTable GetDataTable(string sql, bool isprocedure = false, IIntwentySqlParameter[] parameters = null);
Task<DataTable> GetDataTableAsync(string sql, bool isprocedure = false, IIntwentySqlParameter[] parameters = null);
int InsertEntity<T>(T entity);
Task<int> InsertEntityAsync<T>(T entity);
int InsertEntity(IIBasicDbTable model, JsonElement data);
Task<int> InsertEntityAsync(IIBasicDbTable model, JsonElement data);
int UpdateEntity<T>(T entity);
Task<int> UpdateEntityAsync<T>(T entity);
bool UpdateEntity(IIBasicDbTable model, JsonElement data);
Task<bool> UpdateEntityAsync(IIBasicDbTable model, JsonElement data);
int DeleteEntity<T>(T entity);
Task<int> DeleteEntityAsync<T>(T entity);
bool DeleteEntity(IIBasicDbTable model, string id);
Task<bool> DeleteEntityAsync(IIBasicDbTable model, string id);
bool DeleteEntity(IIBasicDbTable model, int id);
Task<bool> DeleteEntityAsync(IIBasicDbTable model, int id);
List<TypeMapItem> GetDbTypeMap();
List<CommandMapItem> GetDbCommandMap();
Annotations
Intwenty.DataClient uses it own set of annotations to support ORM functions
[DbTableIndex("IDX_1", false, "Col2")]
[DbTablePrimaryKey("Col1")]
[DbTableName("MyDbTable")]
public class Example
{
public int Col1 { get; set; }
public int Col2 { get; set; }
[DbColumnName("MyDbColumn")]
public string Col3 { get; set; }
[NotNull]
public int Col4 { get; set; }
[Ignore]
public int Col5 { get; set; }
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- MySqlConnector (>= 2.3.7)
- Npgsql (>= 8.0.3)
- System.Data.SqlClient (>= 4.8.6)
- System.Data.SQLite.Core (>= 1.0.118)
- System.Runtime.Caching (>= 8.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Intwenty.DataClient:
Package | Downloads |
---|---|
Intwenty
Create metadata driven applications with barea.js and Net 8. Use this package with visual studio 2022 or later. See https://github.com/Domitor/Intwenty for instructions about using this package. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
3.0.0 | 176 | 4/3/2025 |
2.0.0 | 187 | 5/15/2024 |
1.1.2 | 1,266 | 6/22/2021 |
1.1.1 | 453 | 6/15/2021 |
1.1.0 | 3,168 | 12/30/2020 |
1.0.9 | 542 | 12/12/2020 |
1.0.8 | 1,274 | 11/29/2020 |
1.0.7 | 474 | 11/21/2020 |
1.0.6 | 645 | 11/17/2020 |
1.0.5 | 703 | 11/10/2020 |
1.0.4 | 511 | 11/4/2020 |
1.0.3 | 491 | 11/4/2020 |
1.0.2 | 956 | 10/9/2020 |
1.0.1 | 503 | 10/9/2020 |
1.0.0 | 752 | 10/9/2020 |
Added feature: ModifyTable<T>, which creates a table if not existing or adds non existing columns to an existing table.