Update exp to sql

This commit is contained in:
skx 2020-11-07 16:50:42 +08:00
parent e294f64298
commit 575a9e31b5
3 changed files with 49 additions and 0 deletions

View File

@ -92,6 +92,7 @@
<Compile Include="_OldTest\BugTest\BugModels\TStock.cs" />
<Compile Include="_OldTest\BugTest\BugModels\TTempStock.cs" />
<Compile Include="_OldTest\BugTest\BugModels\VMaterialInfo.cs" />
<Compile Include="_OldTest\BugTest\Bug3t.cs" />
<Compile Include="_OldTest\Demos\H_Queue.cs" />
<Compile Include="_OldTest\Demos\I_InsertOrUpdate.cs" />
<Compile Include="_OldTest\Demos\J_Debugger.cs" />

View File

@ -0,0 +1,46 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest.Test
{
public class BugTest
{
public static void Init()
{
SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = Config.ConnectionString,
DbType = DbType.SqlServer,
IsAutoCloseConnection = true,
//MoreSettings = new ConnMoreSettings()
//{
// PgSqlIsAutoToLower = true //我们这里需要设置为false
//},
InitKeyType = InitKeyType.Attribute,
});
//调式代码 用来打印SQL
Db.Aop.OnLogExecuting = (sql, pars) =>
{
Console.WriteLine(sql);
};
var list2 = Db.Queryable<Order, OrderItem, Custom>((o, i, c) => new JoinQueryInfos(
JoinType.Left, o.Id == i.OrderId,
JoinType.Left, c.Id == o.CustomId
))
.Select((o,i,c) => new Order
{
Id=SqlFunc.IsNull(
SqlFunc.Subqueryable<Order>().Where(f=>f.CreateTime>Convert.ToDateTime( o.CreateTime.AddDays(-1)) ).Select(f => f.Id)
,-1)
}).ToList();
}
}
}

View File

@ -127,6 +127,7 @@ namespace SqlSugar
copyContext.RefreshMapping = this.RefreshMapping;
copyContext.ParameterIndex = this.ParameterIndex;
copyContext.PgSqlIsAutoToLower = this.PgSqlIsAutoToLower;
copyContext.IsSingle = this.IsSingle;
return copyContext;
}
public ExpressionContext GetCopyContextWithMapping()
@ -141,6 +142,7 @@ namespace SqlSugar
copyContext.InitMappingInfo = this.InitMappingInfo;
copyContext.RefreshMapping = this.RefreshMapping;
copyContext.PgSqlIsAutoToLower = this.PgSqlIsAutoToLower;
copyContext.IsSingle = this.IsSingle;
return copyContext;
}
#endregion