zoukankan      html  css  js  c++  java
  • Bitter.Core系列二:Bitter ORM NETCORE ORM 全网最粗暴简单易用高性能的 NETCore ORM 之数据库连接

    如果你需要的是 .NETFRAMEWORK 版本的,请移步到:https://www.cnblogs.com/davidchild/p/14617771.html 参考配置

    Bitter.Core NETCore 相当的简单易用,下面附上使用示例:

    数据中连接:请在你的NETCORE 项目中 创建:Bitter.json 配置文件,然后追加如下配置内容:

    1. MSSQL 连接(读写分离配置对),如果读写分离都指向同一个库的话,那么也需要这样配置,只是,配置的Value 的字符串保持一致就行。
    {
    
      "connectionString":[
        {
        
         "dbType": "System.Data.SqlClient",
          "name": "MainData.Reader", 
          "value": "Min Pool Size=10;Max Pool Size=500;Connection Timeout=50;Data Source=192.168.99.66,12033;Initial Catalog=readdbname;Persist Security Info=True;User ID=username;Password=pwd; pooling=false"
        },
        {
    
          "dbType": "System.Data.SqlClient",
          "name": "MainData.Writer",
          "value": "Min Pool Size=10;Max Pool Size=500;Connection Timeout=50;Data Source=192.168.99.66,12033;Initial Catalog=writedbname;Persist Security Info=True;User ID=test;Password=pwd; pooling=false"
        }
       
       ] 
    }
     
    2.MySql 连接(读写分离配置对),如果读写分离都指向同一个库的话,那么也需要这样配置,只是,配置的 Value 的字符串保持一致就
    {
    
      "connectionString":[
        {
         "dbType": "MySql.Data.MySqlClient",
          "name": "MainData.Reader", 
          "value": "Server=.;Port=3306;Database=dbname;Uid=root;Pwd=pwd;Charset=utf8;SslMode=none;Allow User Variables=True;"
        },
        {
    
          "dbType": "MySql.Data.MySqlClient",
          "name": "MainData.Writer",
          "value": "Server=.;Port=3306;Database=dbname;Uid=root;Pwd=pwd;Charset=utf8;SslMode=none;Allow User Variables=True;"
        }
       
       ] 
    }
    3.接配置(读写分离配置对)
    {
    
      "connectionString":[
        {
          "dbType": "System.Data.SqlClient",
          "name": "MainData.Reader",
          "value": "Min Pool Size=10;Max Pool Size=500;Connection Timeout=50;Data Source=192.168.99.66,12033;Initial Catalog=readdbname_1;Persist Security Info=True;User ID=username;Password=pwd; pooling=false"
        },
        {
    
          "dbType": "System.Data.SqlClient",
          "name": "MainData.Writer",
          "value": "Min Pool Size=10;Max Pool Size=500;Connection Timeout=50;Data Source=192.168.99.66,12033;Initial Catalog=writedbname_1;Persist Security Info=True;User ID=test;Password=pwd; pooling=false"
        },
           
        {
          "dbType": "System.Data.SqlClient",
          "name": "database2.Reader",   //注意,name 的值可以自定义,我这里为了方便,先取值为database2, 后面的 Reader 代表着读库 在之后的数据操作代码中在多库连接操作中会使用到。
          "value": "Min Pool Size=10;Max Pool Size=500;Connection Timeout=50;Data Source=192.168.99.66,12033;Initial Catalog=readdbname_1;Persist Security Info=True;User ID=username;Password=pwd; pooling=false"
        },
        {
    
          "dbType": "System.Data.SqlClient",
          "name": "database2.Writer", //注意,name 的值可以自定义,我这里为了方便,先取值为database2, 后面的 Writer 代表着写库 在之后的数据操作代码中在多库连接操作中会使用到。
          "value": "Min Pool Size=10;Max Pool Size=500;Connection Timeout=50;Data Source=192.168.99.66,12033;Initial Catalog=writedbname_1;Persist Security Info=True;User ID=test;Password=pwd; pooling=false"
        }
       
       ] 
    }
  • 相关阅读:
    [JXOI2018]游戏
    UltraISO制作启动盘安装CentOS7
    龙芯、鲲鹏、飞腾等国产平台的浏览器
    浏览器相关性能测试网址
    有没有一种组合字体,中文是宋体,英文是times new roman?
    中国航天科工集团第二研究院706所招聘
    华为云
    面试阿里P6难在哪?(面试难点)
    Linux下配置环境变量—— .bashrc 和 /etc/profile
    Linux 内存 占用较高问题排查
  • 原文地址:https://www.cnblogs.com/davidchild/p/14276611.html
Copyright © 2011-2022 走看看