Skip to content

新仓库地址: https://gitee.com/jackletter/DBUtil 运行平台:.net standard2.0;支持数据库:sqlserver、mysql、oracle、postgresql、sqlite

Notifications You must be signed in to change notification settings

jackletter/DBUtil.Standard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

注意:相比windows版本的dbutil,这个包不支持access、excel等oledb连接,sqlite数据库不支持密码

DBUtil.Standard

.net standard 2.0 下常用的数据库访问工具,支持sqlserver、oracle、mysql、postgresql、sqlite 运行平台:.net standard 2.0

使用说明

  1. 安装依赖:
Install-Package DBUtil.Standard -Version 1.0.0
  1. 创建数据库操作对象
DBUtil.IDbAccess iDb = DBUtil.IDBFactory.CreateIDB("Data Source=.;Initial Catalog=JACKOA;User ID=sa;Password=xx;","SQLSERVER");
  1. 查询
String str=iDb.GetFirstColumnString("select Name from SysUser");
DataTable dt = iDb.GetDataTable("select * from test2");
DataSet ds = iDb.GetDataSet("select * from test2;select * from test2;"); 
  1. 分页查询
DBUtil.IDbAccess iDb = DBUtil.IDBFactory.CreateIDB(@"Data Source=localhost;Initial Catalog=imgserver2;User ID=root;Password=123456;", "MYSQL");
string selectSql = "select * from test2";
string orderSql = "order by id desc";
int pageSize = 10;
int pageIndex = 1;
string sqlFinal = iDb.GetSqlForPageSize(selectSql, orderSql, pageSize, pageIndex);
Console.WriteLine(sqlFinal);//select * from test2 order by id desc limit 0,10
  1. 参数化sql
DataTable dt = iDb.GetDataTable(string.Format("select * from test2 where name like {0}", iDb.paraPrefix + "name"), new IDbDataParameter[] {
      iDb.CreatePara("name","%小%")
 });
  1. ID生成
int id = iDb.IDSNOManager.NewID(iDb, "test", "id");

About

新仓库地址: https://gitee.com/jackletter/DBUtil 运行平台:.net standard2.0;支持数据库:sqlserver、mysql、oracle、postgresql、sqlite

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages