JCoder.Db4Net
2.11.4
See the version list below for details.
dotnet add package JCoder.Db4Net --version 2.11.4
NuGet\Install-Package JCoder.Db4Net -Version 2.11.4
<PackageReference Include="JCoder.Db4Net" Version="2.11.4" />
paket add JCoder.Db4Net --version 2.11.4
#r "nuget: JCoder.Db4Net, 2.11.4"
// Install JCoder.Db4Net as a Cake Addin #addin nuget:?package=JCoder.Db4Net&version=2.11.4 // Install JCoder.Db4Net as a Cake Tool #tool nuget:?package=JCoder.Db4Net&version=2.11.4
JCoder.Db4Net
属性 | |
---|---|
作者(Authors) | Jackie Law |
版权(Copyright) | Copyright © Jackie Law. All rights reserved. |
协议 | MIT |
联系(QQ) | 1378071853 |
联系(微信) | JackieLaw1024 |
联系(Email) | JackieLaw-dev@outlook.com |
目录
[TOC]
介绍
- JCoder = Jackie who a coder.;
- C#库;
- Database类库,一款为方便使用数据库的操作类库。
架构说明
.Net框架
.Net框架 | .Net项目类型 |
---|---|
.Net Standard2.1 | - |
.Net Framework 4.7.2 | - |
.Net 5 | - |
.Net 6 | - |
引用类库
引用类库 | 版本 |
---|---|
- | - |
相关类库
相关类库 | 说明 |
---|---|
JCore.Db4Net | 一款为方便使用数据库的操作类库。 |
JCore.Db4Net.ORM | 一个基于JCore.Db4Net的ORM库。 |
JCore.Db4Net.Sqlite | 一个基于JCore.Db4Net且支持Sqlite的库。 |
JCore.Db4Net.MySql | 一个基于JCore.Db4Net且支持Mysql的库。 |
JCore.Db4Net.SqlServer | 一个基于JCore.Db4Net且支持SqlServer的库。 |
JCoder.Db4Net | 一款为方便使用数据库的操作类库,JCore.Db4Net的新版本。 |
JCoder.Db4Net.ORM | 一个基于JCoder.Db4Net的ORM库,JCore.Db4Net.ORM的新版本。 |
JCoder.Db4Net.Sqlite | 一个基于JCoder.Db4Net且支持Sqlite的库,JCore.Db4Net.Sqlite的新版本。 |
JCoder.Db4Net.MySql | 一个基于JCoder.Db4Net且支持Mysql的库,JCore.Db4Net.MySql的新版本。 |
JCoder.Db4Net.SqlServer | 一个基于JCoder.Db4Net且支持SqlServer的库,JCore.Db4Net.SqlServer的新版本。 |
获取方式
- 版本要求:>=2.3.1
- 以版本2.3.1为例
获取方式 | 描述 |
---|---|
Package Manager | Install-Package JCoder.Db4Net -Version 2.3.1 |
.Net CLI | dotnet add package JCoder.Db4Net --version 2.3.1 |
PackageReference | <PackageReference Include="JCoder.Db4Net" Version="2.3.1" /> |
Paket CLI | paket add JCoder.Db4Net --version 2.3.1 |
Script&Interactive | #r "nuget: JCoder.Db4Net, 2.3.1" |
Cake | // Install as a Cake Addin<br/>#addin nuget:?package=JCoder.Db4Net&version=2.3.1<br/><br/>// Install as a Cake Tool<br/>#tool nuget:?package=JCoder.Db4Net&version=2.3.1 |
使用说明
创建实例
MySql
需要先在项目里引用或加载MySql官方库MySql.Data.dll。
IDbOperator _operator = new MySqlFactoryOperator() { ConnectionString = "server=127.0.0.1;database=test;uid=user;pwd=testpassword;Connect Timeout=18000" };
SQLite
需要先在项目里引用或加载Sqlite官方库System.Data.SQLite.dll。
IDbOperator _operator = new SQLiteFactoryOperator() { ConnectionString = "Data Source=.\data\test.db3;" };
Sql Server
需要先在项目里引用或加载Sql Server官方库System.Data.SqlClient.dll。
IDbOperator _operator = new SqlServerFactoryOperator() { ConnectionString = "Server=127.0.0.1;Database=test;Uid = user; Pwd=testpassword;" };
实例使用
CanConnect(是否能够连接数据库)
// CanConnect(是否能够连接数据库) if (_operator.CanConnect()) { return; }
CreateParameter(创建相应的参数)
// CreateParameter(创建相应的参数) return _operator.CreateParameter( "ID", 123);
Execute(执行SQL)
// Execute(执行SQL) var _parameters = new List<DbParameter>() { _operator.CreateParameter("ID","ID123"), _operator.CreateParameter("Name","Name123"), _operator.CreateParameter("CreateTime",DateTime.Now), }; var _sql = @"insert table1 (ID,Name,CreateTime) values (@ID,@Name,@CreateTime);"; var _count = _operator.Execute(_sql, _parameters);//直接执行SQL //var _count = _operator.Execute(true,_sql, _parameters);// 使用事务执行SQL return _count >= 1;
ExecuteTransaction(使用指定的事务执行指定的SQL)
// ExecuteTransaction(使用指定的事务执行指定的SQL) public void ExecuteTransaction() { for (int i = 0; i < 3; i++) { var _key = "Transaction" + i.ToString(); _operator.StartTransaction(_key); var _id = i.ToString() + DateTime.Now.ToLongTimeString(); try { var _parameters = new List<DbParameter>() { _operator.CreateParameter("ID",_id), _operator.CreateParameter("Name","Name123"), _operator.CreateParameter("CreateTime",DateTime.Now), }; var _sql = @"insert table1 (ID,Name,CreateTime) values (@ID,@Name,@CreateTime);"; var _isSucceed = _operator.ExecuteTransaction(_key, _sql, _parameters); } catch (Exception ex) { _operator.RollbackTransaction(_key); return; } if (!_operator.FinishTransaction(_key)) { return; } } }
RollbackTransaction(回滚指定的事务)
// RollbackTransaction(回滚指定的事务) public void RollbackTransaction() { var _key = "Transaction"; _operator.StartTransaction(_key); var _id = nameof(RollbackTransaction); try { var _parameters = new List<DbParameter>() { _operator.CreateParameter("ID",_id), _operator.CreateParameter("Name","Name123"), _operator.CreateParameter("CreateTime",DateTime.Now), }; var _sql = @"insert table1 (ID,Name,CreateTime) values (@ID,@Name,@CreateTime);"; var _isSucceed = _operator.ExecuteTransaction(_key, _sql, _parameters); } catch (Exception ex) { _operator.RollbackTransaction(_key); return; } _operator.RollbackTransaction(_key); }
QueryTable(查询数据,并返回DataTable)
// QueryTable(查询数据,并返回DataTable) public DataTable QueryTable() { var _parameters = new List<DbParameter>() { _operator.CreateParameter("ID",123), }; var _sql = "select * from table1 where ID=@ID;"; var _table = _operator.QueryTable(_sql, _parameters); return _table; }
QueryReader(查询数据,并返回DbDataReader)
// QueryReader(查询数据,并返回DbDataReader) public QueryReader QueryReader() { var _parameters = new List<DbParameter>() { _operator.CreateParameter("ID",123), }; var _sql = "select * from table1 where ID=@ID;"; var _reader = _operator.QueryReader(_sql, _parameters); return _reader; }
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. 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 | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
.NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.7.2
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
-
net5.0
- No dependencies.
-
net6.0
- No dependencies.
NuGet packages (6)
Showing the top 5 NuGet packages that depend on JCoder.Db4Net:
Package | Downloads |
---|---|
JCoder.Db4Net.Sqlite
A library based on JCoder.Db4Net and it support Sqlite. (一个基于JCoder.Db4Net且支持Sqlite的库) |
|
JCoder.Db4Net.ORM
A ORM library based on the JCoder.Db4Net. (基于JCoder.Db4Net的ORM库) |
|
JCoder.Db4Net.MySql
A library based on JCoder.Db4Net and it support Mysql.(一个基于JCoder.Db4Net且支持Mysql的库) |
|
JCoder.Db4Net.SqlServer
A library based on JCoder.Db4Net and it support microsoft sql server. (一个基于JCoder.Db4Net且支持sql server的库) |
|
JCoder.Extension.SqliteAssistKitsts
一款使用Sqlite进行辅助的工具库。 |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.13.2 | 39 | 11/7/2024 |
3.13.1 | 36 | 11/7/2024 |
3.12.1 | 196 | 11/3/2024 |
3.11.1 | 135 | 11/1/2024 |
3.10.1 | 64 | 11/1/2024 |
3.9.8 | 252 | 9/17/2024 |
3.9.7 | 203 | 9/8/2024 |
3.9.6 | 202 | 8/30/2024 |
3.9.5 | 190 | 8/30/2024 |
3.9.4 | 190 | 8/30/2024 |
3.9.3 | 177 | 8/30/2024 |
3.9.2 | 202 | 8/30/2024 |
3.9.1 | 176 | 8/30/2024 |
3.8.3 | 238 | 8/13/2024 |
3.8.2 | 185 | 7/24/2024 |
3.8.1 | 177 | 7/18/2024 |
3.7.4 | 152 | 7/17/2024 |
3.7.3 | 253 | 4/5/2024 |
3.6.3 | 293 | 4/4/2024 |
3.5.3 | 206 | 1/3/2024 |
3.5.2 | 294 | 12/3/2023 |
3.5.1 | 321 | 10/5/2023 |
3.4.2 | 292 | 10/2/2023 |
2.26.2304.308 | 242 | 4/3/2023 |
2.21.4 | 1,626 | 11/8/2022 |
2.20.12 | 1,229 | 11/4/2022 |
2.19.5 | 1,501 | 10/14/2022 |
2.18.6 | 1,475 | 10/13/2022 |
2.13.3 | 1,476 | 6/5/2022 |
2.12.3 | 1,526 | 5/25/2022 |
2.11.4 | 1,552 | 5/13/2022 |
Please contact Jackie by QQ 1378071853 or E-mail JackieLaw-dev@outlook.com;