SqlSugar/Src/Asp.Net/SqlServerTest/OldTest/Demos/J_Debugger.cs

61 lines
2.1 KiB
C#
Raw Normal View History

2019-01-25 21:45:15 +08:00
using OrmTest.Demo;
using OrmTest.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest.Demo
{
public class Debugger : DemoBase
{
public static void Init()
{
var db = GetInstance();
db.CurrentConnectionConfig.Debugger = new SqlSugar.SugarDebugger() { EnableThreadSecurityValidation = true };
db.Queryable<Student>().ToList();
db.Queryable<Student>().ToListAsync().Wait();
2019-01-25 22:56:18 +08:00
db.Insertable<Student>(new Student() { Name = "a" }).ExecuteCommandAsync().Wait();
db.Updateable<Student>(new Student() { Name = "a" }).ExecuteCommandAsync().Wait();
db.Deleteable<Student>(1111).ExecuteCommandAsync().Wait();
2019-01-25 22:40:19 +08:00
var task = new Task(() =>
{
try
{
//is error
2019-01-25 22:47:28 +08:00
Console.WriteLine("is error");
2019-01-25 22:40:19 +08:00
db.Queryable<Student>().ToList();
}
catch (Exception ex)
2019-01-25 21:45:15 +08:00
{
2019-01-25 22:55:08 +08:00
Console.WriteLine(ex.Message);
2019-01-25 22:40:19 +08:00
}
});
task.Start();
task.Wait();
2019-01-25 21:45:15 +08:00
2019-01-25 22:47:28 +08:00
for (int i = 0; i < 10; i++)
2019-01-25 21:45:15 +08:00
{
2019-01-25 22:47:28 +08:00
var task2 = new Task(() =>
{
//is ok
Console.WriteLine("is ok");
var db2 = GetInstance();
db2.CurrentConnectionConfig.Debugger = new SqlSugar.SugarDebugger() { EnableThreadSecurityValidation = true };
db2.Queryable<Student>().ToList();
2019-01-25 22:55:08 +08:00
db2.Queryable<Student>().ToList();
2019-01-25 22:47:28 +08:00
});
task2.Start();
task2.Wait();
}
2019-01-25 21:45:15 +08:00
}
}
}