Hikari 2.8.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Hikari --version 2.8.2                
NuGet\Install-Package Hikari -Version 2.8.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Hikari" Version="2.8.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Hikari --version 2.8.2                
#r "nuget: Hikari, 2.8.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Hikari as a Cake Addin
#addin nuget:?package=Hikari&version=2.8.2

// Install Hikari as a Cake Tool
#tool nuget:?package=Hikari&version=2.8.2                

HiKari使用说明

已经提交nuget(Hikari)
郑重说明:本库HiKari定位于数据库连接池,源码GitHub开源公开,欢迎大家修改提交
其它功能建议以Hikari.Integration.XXXX(名称)库,引用当前库进行扩展

程序初始化

使用配置类

      HikariConfig hikariConfig = new HikariConfig();
                   hikariConfig.DBType = "PostgreSQL";
                   hikariConfig.ConnectString = "Server = 127.0.0.1; Port = 5432; User Id = postgres; Password = 1234; Database =      postgres;Pooling=true; ";
                   hikariConfig.DriverDir = "DBDrivers";
                   hikariConfig.DriverDLL = "XXXX.dll";
                   hikariConfig.DBTypeXml = "DBType.xml";
      HikariDataSource hikariDataSource = new HikariDataSource(hikariConfig);

配置文件(推荐方式):

HikariConfig hikariConfig = new HikariConfig();
hikariConfig.LoadConfig("Hikari.txt");
HikariDataSource hikariDataSource = new HikariDataSource(hikariConfig);

使用连接 hikariDataSource.GetConnection();

使用批量处理接口 var bulk= hikariDataSource.GetBulkCopy();
说明:我的博文中总结了几种批量处理的方式,唯独数据库提供的专门用于批量插入的类需要底层客户端驱动提供,所以增加了接口,满足调用这些类处理批量插入

使用多库管理类
例如:配置文件MySql_HiKari.cfg
ManagerPool.Singleton.GetDbConnection(MySql);
ManagerPool.Singleton.GetBulkCopy(MySql);

配置文件说明

1.连接字符串必须要
2.驱动目录DriverDir项不配置则使用默认drivers目录
3.关于驱动dll有2种:
(1)直接在配置文件中配置DriverDLL项,这个时候不需要DBType配置项
(2)DBType项和DBType.xml结合使用,这时不需要单独在每个连接配置中配置DriverDLL。
这个时候连接池查找dll的方式:
1>DBType配置是默认的4类,则无需DBType.xml来查找dll文件名称。
2>DBType配置不是默认的4类,则需要BType.xml中的配置来获取DLL文件名称。因为程序不知道dll.
其实这2种就是分散与汇总的区别。有的习惯每个配置文件配置dll,方便监测;有的习惯写在一起,方便管理。看自己情况。
DBType程序中写死了4种,见附录。
DBType.xml我称为全局配置文件,读取时的配置路径和名称可以设置HikariConfig或者HikariDataSource的DBTypeXml属性进行修改;默认就是DBType.xml


源码简说

基本内容

HikariDataSource 对外提供连接
HikariConfig 对外配置
HikariPool 管理操作集合,连接来源
PoolBase 操作驱动连接,是HikariPool父类


扩展项目

Hikari.Integration.Entity
采用emit将DataTable,IDataReader转换成List<T>,同理将List<T>转成DataTable
内部调用EntityMappingDB项目

使用扩展方法ToEntity 转换  
使用扩展方法FromEntity 转换  
如果带特性则使用扩展方法FromEntityAttribute  转换  

说明:因为Hikari项目定位连接池,不能随意扩展功能和类,所以转换以扩展项目的方式提供


扩展功能

HikariDataSource,ManagerPool通过扩展方法封装了SQL基本操作

说明:这里只是方便操作,尤其是返回DataSet,按照项目定位是不应该的,所以使用的是扩展方法

附录

数据库 Dll名称 说明
Oracle Oracle.ManagedDataAccess 以前不是这个dll
MySql MySql.Data
SqlServer System
PostgreSQL Npgsql
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Hikari:

Package Downloads
HikariAPI

提供Hikari实现ORM;完善配置文件方式,各类参数执行,支持匿名类使用;扩展字符串类实现直接SQL参数化语句使用方法调用,SQLParameterExtension类

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.2 262 1/14/2024
3.0.1 109 1/14/2024
3.0.0 112 1/14/2024
2.9.9 176 9/25/2023
2.9.8 151 9/24/2023
2.9.7 148 9/23/2023
2.9.6 143 9/20/2023
2.9.5 182 6/23/2023
2.9.4 185 6/22/2023
2.9.3 165 6/20/2023
2.9.2 189 5/15/2023
2.9.1 170 5/13/2023
2.9.0 211 4/22/2023
2.8.7 480 10/2/2021
2.8.6 371 10/2/2021
2.8.5 1,333 5/12/2019
2.8.4 672 5/12/2019
2.8.3 730 4/11/2019
2.8.2 706 4/5/2019
2.8.1 717 4/1/2019
2.8.0 765 3/31/2019
2.7.5 737 3/30/2019
2.7.4 739 3/30/2019
2.7.3 781 2/24/2019
2.7.2 743 2/21/2019
2.7.1 820 2/15/2019
2.7.0 836 2/15/2019
2.6.3 1,042 1/27/2019
2.6.2 1,061 1/26/2019
2.6.1 1,033 1/26/2019
2.6.0 1,072 1/26/2019
2.5.0 833 1/26/2019
2.3.0 1,043 1/26/2019
2.2.0 856 1/24/2019
2.1.0 825 1/23/2019
2.0.0 861 1/4/2019
1.3.0 915 1/4/2019

郑重说明:本库定位于数据库连接池,源码GitHub开源公开,欢迎大家修改提交,但是不得对本库扩展,所有修改仅限于bug,性能优化,存储数据结构优化重构等。一切需要扩展的功能都需要你单独建库(项目),建议以Hikari.Integration.XXX(名称)库,引用当前库进行扩展