隐藏

Mysql与Sqlsugar字符串

发布:2023/3/19 13:22:41作者:管理员 来源:本站 浏览次数:767

SqlSugar.5.0.5.4

MySql.Data.8.0.28


using SqlSugar;

using System;

using System.Collections.Generic;

using System.Configuration;

using System.Linq;

using System.Text;

using System.Threading.Tasks;


namespace DAL

{

   public class SqlSugarHelper

   {

       public static string ConnectionString = string.Empty; //必填, 数据库连接字符串

       public static SqlSugarClient db

       {

           get => new SqlSugarClient(new ConnectionConfig()

           {

               //ConnectionString = ConfigurationManager.ConnectionStrings["connString"].ToString(),

               ConnectionString = "database='" + "shenhuadata" + "';Data Source = '" + "127.0.0.1" + "'; User Id = '" + "root" + "'; pwd='" + "sasa" + "';charset='utf8';pooling=true",

               //ConnectionString = ConnectionString,

               DbType = SqlSugar.DbType.MySql,         //必填, 数据库类型

               IsAutoCloseConnection = true,       //默认false, 时候知道关闭数据库连接, 设置为true无需使用using或者Close操作

               InitKeyType = InitKeyType.SystemTable    //默认SystemTable, 字段信息读取, 如:该属性是不是主键,是不是标识列等等信息

           });

       }

   }

}



       //定义根目录路径

       private static string FilePath = System.IO.Directory.GetCurrentDirectory() + "\\ConfigFile\\";

       //读取配置文件路径,ini要是ANSI格式

       SettingManager IniManager = new SettingManager(FilePath + "MODBUSTCP_.ini");


       private CancellationTokenSource cts = new CancellationTokenSource();


       //插入数据库

       InsertDataSQLite objInsert = new InsertDataSQLite(10000);//10秒1次