SqlSugar/Src/Asp.Net/SqlServerTest/Demo/Demo1_Queryable.cs
2019-05-09 17:16:45 +08:00

47 lines
1.1 KiB
C#

using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OrmTest
{
public class Demo1_Queryable
{
public static void Init()
{
Async();
}
private static void Async()
{
Console.WriteLine("");
Console.WriteLine("#### Async Start ####");
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
AopEvents = new AopEvents
{
OnLogExecuting = (sql, p) =>
{
Console.WriteLine(sql);
}
}
});
var task1 = db.Queryable<Order>().FirstAsync();
var task2 = db.Queryable<Order>().Where(it => it.Id == 1).ToListAsync();
task1.Wait();
task2.Wait();
Console.WriteLine("#### Async End ####");
}
}
}