mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Update README.md
This commit is contained in:
parent
2a020d888d
commit
fc30f3731d
26
README.md
26
README.md
@ -72,3 +72,29 @@ SELECT [Id],[Name],[Price],[CreateTime],[CustomId]
|
|||||||
([Name] like '%'+ CAST(@MethodConst1 AS NVARCHAR(MAX))+'%')
|
([Name] like '%'+ CAST(@MethodConst1 AS NVARCHAR(MAX))+'%')
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
## Multi-tenant transaction
|
||||||
|
```cs
|
||||||
|
//Creaate database object
|
||||||
|
SqlSugarClient db = new SqlSugarClient(new List<ConnectionConfig>()
|
||||||
|
{
|
||||||
|
new ConnectionConfig(){ ConfigId="0", DbType=DbType.SqlServer, ConnectionString=Config.ConnectionString, IsAutoCloseConnection=true },
|
||||||
|
new ConnectionConfig(){ ConfigId="1", DbType=DbType.MySql, ConnectionString=Config.ConnectionString4 ,IsAutoCloseConnection=true}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var mysqldb = db.GetConnection("1");//mysql db
|
||||||
|
var sqlServerdb = db.GetConnection("0");// sqlserver db
|
||||||
|
|
||||||
|
db.BeginTran();
|
||||||
|
mysqldb.Insertable(new Order()
|
||||||
|
{
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
CustomId = 1,
|
||||||
|
Name = "a",
|
||||||
|
Price = 1
|
||||||
|
}).ExecuteCommand();
|
||||||
|
mysqldb.Queryable<Order>().ToList();
|
||||||
|
sqlServerdb.Queryable<Order>().ToList();
|
||||||
|
|
||||||
|
db.CommitTran();
|
||||||
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user