连接字符串:server=.;uid=sa;pwd=haosql;database=SQLSUGAR4XTEST
//单个设置 db.Queryable<Order>().With(SqlWith.NoLock).ToList() //全局设置 var db= new SqlSugarClient(new ConnectionConfig() { DbType = SqlSugar.DbType.SqlServer, ConnectionString = Config.ConnectionString, InitKeyType = InitKeyType.Attribute, IsAutoCloseConnection = true, MoreSettings=new ConnMoreSettings() { IsWithNoLockQuery=true//看这里 }, AopEvents = new AopEvents { OnLogExecuting = (sql, p) => { Console.WriteLine(sql); Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value))); } } }); //取消全局nolock db.Queryable<Order>().With(SqlWith.Null).ToList()
自带的批量插入性能已经非常出色了,当字段数特别多,数据量太大的时候可以使用,缺点无法获取Sql
db.Insertable(insertObjs).UseSqlServer().ExecuteBlueCopy();
2016 © donet5.comApache Licence 2.0