SqlSugar/Src/Asp.Net/SqlServerTest/UnitTest/Setting/AutoClose.cs

33 lines
864 B
C#
Raw Normal View History

2017-04-30 17:26:45 +08:00
using OrmTest.Models;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest.UnitTest
{
2017-05-16 13:55:57 +08:00
public class AutoClose : UnitTestBase
2017-04-30 17:26:45 +08:00
{
2017-04-30 19:45:14 +08:00
public AutoClose(int eachCount)
{
this.Count = eachCount;
}
2017-04-30 17:26:45 +08:00
public void Init()
{
2017-04-30 19:45:14 +08:00
//IsAutoCloseConnection
for (int i = 0; i < this.Count; i++)
2017-04-30 17:26:45 +08:00
{
2017-04-30 19:45:14 +08:00
var db = GetInstance();
var x = db.Queryable<Student>().ToList();
2017-04-30 17:26:45 +08:00
}
}
public SqlSugarClient GetInstance()
{
2017-05-28 10:01:58 +08:00
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
2017-04-30 17:26:45 +08:00
return db;
}
}
}