# DbSqlHelper **Repository Path**: EnCode/DbSqlHelper ## Basic Information - **Project Name**: DbSqlHelper - **Description**: 数据库操作助手,另一种ORM(异构操作,不再需要额外的建模) - **Primary Language**: C# - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2015-12-01 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #DbSqlHelper ##数据库结构 ``` create table people( pid int not null, pcode varchar(255) not null, pname varchar(255) not null, primary key(pid asc) ) ``` ##异构模型 ``` class user{ public int? id{get;set;} public string code{get;set;} public string name{get;set;} } ``` ##Insert用例 ``` SqlCommand cmd = ...; // 初始化 var p1 = new user(){id = 1, code = "001", name = "zhang"}; var tablename = "people"; var maps = new Dictionary() // 同名的字段不需要映射 { { "pid", "id" }, { "pcode", "code" }, { "pname", "name" } }; var fields = "pid,pcode,pname"; DbSqlHelper.Insert(cmd, tablename, maps, p1, fields); ```