Currently only supports MYSQL version 3.5.2.9, its library version December 3 update this feature
Use cases to explain
using (var db = new SqlSugarClient ( " primary connection string", "from the connection string" "can be connected to a plurality of slave")) { var = db.Queryable List <Student> () ToList ();. // away from the var list = db.Queryable <Student> ( ) toJson ();. // away from the db.Insert (new Student () {name = " write"}); // take the main db.Delete (new Student () {id = 1}) ; // go main db.BeginTran // operations are the primary transaction }
Explanation
/// <Summary> /// new instance (master-slave mode) class initialization SqlSugarClient /// </ Summary> /// <param name = "masterConnectionString"> Main: write transactions and other operations </ param> / // <param name = "slaveConnectionString" > from: no transaction reads </ param> public SqlSugarClient (String masterConnectionString, the params String [] slaveConnectionString) : Base (masterConnectionString, slaveConnectionString) { the ConnectionString = masterConnectionString; }
note:
ORM is the perfect support for the separation of master and slave, but you also need to set up your database before they can open the main synchronization from, for example, SqlServer have alwayson technology.
If you do not know SqlSugar ORM Please check http://www.codeisbug.com/Home/Doc?typeId=7