万事须己运,他得非我贤。这篇文章主要讲述dapper的使用相关的知识,希望能为你提供帮助。
public abstract class AsbCommection { private static string con = System.Configuration.ConfigurationManager.ConnectionStrings["con"].ConnectionString; public static IDbConnection GetConnection() { IDbConnection conn = new SqlConnection(con); if (conn.State == ConnectionState.Closed) { conn.Open(); } return conn; } }
public interface IDAL { List< Tresult> Show< Tresult> (string sql) where Tresult : class, new(); int Insert(string sql); int Del(string sql); } public class SqlDBHelper : IDAL { private IDbConnection conn = AsbCommection.GetConnection(); public int Del(string sql) { return conn.Execute(sql); }public int Insert(string sql) { return conn.Execute(sql); }public List< Tresult> Show< Tresult> (string sql) where Tresult : class, new() { return conn.Query< Tresult> (sql).ToList(); } }
public class RoweBLL { SqlDBHelper db = new SqlDBHelper(); public List< RoweModel> ShowRowe(string YName) { if (YName ==null||YName=="") { string sql = "select * from YueKao0707TB s join YuekaoType e on s.TId=e.TId"; return db.Show< RoweModel> (sql); } else { string sql = $"select * from YueKao0707TB s join YuekaoType e on s.TId=e.TId where YName like ‘{"%" + YName + "%"}‘"; return db.Show< RoweModel> (sql); }} public int InsertRowe(RoweModel m) { string sql = $"insert into YueKao0707TB values(‘{m.YName}‘,‘{m.TId}‘,‘{m.ZPrco}‘,‘{m.SPrco}‘,‘{m.ZNum}‘,‘{m.SNum}‘,‘{m.HStrac}‘)"; return db.Insert(sql); } public List< RoweTypeModel> ShowType() { string sql = "select * from YuekaoType"; return db.Show< RoweTypeModel> (sql); } public int DelRowe(int Id) { string sql = "delete from YueKao0707TB where Id=" + Id; return db.Del(sql); } }
【dapper的使用】
推荐阅读
- uni-app实现文件上传功能
- POJ - 3321 Apple Tree (dfs序+线段树)
- ApplicationEventPublisher的使用学习
- Android 调试不显示“USB调试”RSA密钥指纹 认证窗口 不使用助手软件怎么做
- kubectl apply -fservice.yaml
- Unity论坛问答-SRP合批在安卓平台不起作用
- Android Thread 常用方法
- 解决android studio 文本乱码问题
- Android | Android Studio打包APK安装失败(应用是非正式版本,当前设备不支持安装)