mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-25 10:19:17 +08:00
Update exp to sql
This commit is contained in:
@@ -94,6 +94,7 @@
|
||||
<Compile Include="Models\OrderItem.cs" />
|
||||
<Compile Include="Demo\Demo0_SqlSugarClient.cs" />
|
||||
<Compile Include="Models\ViewOrder.cs" />
|
||||
<Compile Include="UnitTest\UCustom01.cs" />
|
||||
<Compile Include="UnitTest\UDelete.cs" />
|
||||
<Compile Include="UnitTest\UFastest.cs" />
|
||||
<Compile Include="UnitTest\UConfig.cs" />
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace OrmTest
|
||||
}
|
||||
public static void Init()
|
||||
{
|
||||
UCustom01.Init();
|
||||
UConfig();
|
||||
DeleteTest();
|
||||
Fastest2();
|
||||
|
||||
71
Src/Asp.Net/SqlServerTest/UnitTest/UCustom01.cs
Normal file
71
Src/Asp.Net/SqlServerTest/UnitTest/UCustom01.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
public class UCustom01
|
||||
{
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
var db = new SqlSugarScope(new SqlSugar.ConnectionConfig()
|
||||
{
|
||||
ConnectionString = Config.ConnectionString,
|
||||
DbType = DbType.SqlServer,
|
||||
IsAutoCloseConnection = true
|
||||
});
|
||||
db.Aop.OnLogExecuted = (s, p) =>
|
||||
{
|
||||
Console.WriteLine(s);
|
||||
};
|
||||
//建表
|
||||
if (!db.DbMaintenance.IsAnyTable("User_Test001", false))
|
||||
{
|
||||
db.CodeFirst.InitTables<User_Test001>();
|
||||
}
|
||||
if (!db.DbMaintenance.IsAnyTable("UserRole_Test001", false))
|
||||
{
|
||||
db.CodeFirst.InitTables<UserRole_Test001>();
|
||||
}
|
||||
|
||||
//用例代码
|
||||
var result = db.Queryable<User_Test001, UserRole_Test001>((u, ur) => new object[] {
|
||||
|
||||
JoinType.Left,u.ID==ur.UserID
|
||||
|
||||
|
||||
|
||||
}).Select((u, ur) => new
|
||||
|
||||
{
|
||||
|
||||
customName = SqlFunc.Subqueryable<User_Test001>().Where(s => s.UserName == u.UserName).Select(s => s.UserName+"")
|
||||
|
||||
|
||||
|
||||
}).ToPageList(1, 10);
|
||||
|
||||
Console.WriteLine(result);
|
||||
Console.WriteLine("用例跑完");
|
||||
Console.ReadKey();
|
||||
}
|
||||
[SugarTable("unitUser_Test001")]
|
||||
public class User_Test001
|
||||
{
|
||||
|
||||
public int ID { get; set; }
|
||||
public string UserName { get; set; }
|
||||
}
|
||||
[SugarTable("unitUserRole_Test001")]
|
||||
public class UserRole_Test001
|
||||
{
|
||||
|
||||
public int ID { get; set; }
|
||||
public int UserID { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user