当前位置:   article > 正文

.NET使用SqlSugar_net sqlsugar

net sqlsugar

webconfig:

  1. <connectionStrings>
  2. <add name="DbConn" connectionString="server=.;database=database;uid=sa;pwd=123456" providerName="System.Data.SqlClient" />
  3. </connectionStrings>

配置链接:

  1. using SqlSugar;
  2. namespace Abcd.DAL
  3. {
  4. public class SqlSugarHelper
  5. {
  6. public static string ConnectionString = ConfigurationManager.ConnectionStrings["DbConn"].ToString();
  7. public static SqlSugarClient _db = null;//SqlSugar对象,所有的操作都在: _db 里 . 出来
  8. public static SqlSugarClient CretClient()
  9. {
  10. _db = new SqlSugarClient(new ConnectionConfig()
  11. {
  12. ConnectionString = ConnectionString, //必填,连接字符串
  13. DbType = DbType.SqlServer, //必填,数据库类型
  14. IsAutoCloseConnection = true,
  15. MoreSettings = new ConnMoreSettings()
  16. {
  17. IsWithNoLockQuery = true
  18. }
  19. });
  20. _db.Ado.CommandTimeOut = 300;//链接超时时间,单位秒
  21. return _db;
  22. }
  23. }
  24. }

调用:

  1. string sql =" ... ";//略
  2. var db = SqlSugarHelper.CretClient();//创建sqlSugar对象
  3. int i = db.Ado.ExecuteCommand(sql);//执行sql语句

SqlSugar官网:  https://www.donet5.com/Home/Doc

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/950655
推荐阅读
相关标签
  

闽ICP备14008679号