Browse Source

Update exp to sql

pull/14/MERGE
sunkaixuan 3 years ago
parent
commit
00f07632fd
  1. 8
      Src/Asp.Net/SqlServerTest/UnitTest/UCustom09.cs
  2. 6
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs

8
Src/Asp.Net/SqlServerTest/UnitTest/UCustom09.cs

@ -19,6 +19,14 @@ namespace OrmTest
db.CodeFirst.InitTables<Unitadfaint21>();
db.Insertable(new Unitadfaint21() { id = 1 , id2=22 }).ExecuteCommand();
var list2 = db.Queryable<Unitadfaint21>().ToList();
var list3=db.Queryable<Order>()
// .Where(it=>SqlFunc.ToString(it.Id>0?1:0)=="")
.Select(it => new
{
count = SqlFunc.AggregateSum(it.Id < 20 ? 1 : 0)
//count = SqlFunc.AggregateSum(SqlFunc.IIF(b.客户确认状态 < 20, 1, 0))
}).ToListAsync();
}
public class Unitadfaint21

6
Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs

@ -547,6 +547,10 @@ namespace SqlSugar
{
parameter.CommonTempData = DateTime.Now.Date;
}
else if (item is ConditionalExpression)
{
parameter.CommonTempData = GetNewExpressionValue(item);
}
else if (IsDateDate(item))
{
parameter.CommonTempData = GetNewExpressionValue(item);
@ -585,7 +589,7 @@ namespace SqlSugar
methodCallExpressionArgs.IsMember = false;
}
}
if (IsDateDate(item) || IsDateValue(item)|| IsDateItemValue(item))
if (IsDateDate(item) || IsDateValue(item)|| IsDateItemValue(item)||item is ConditionalExpression)
{
methodCallExpressionArgs.IsMember = true;
}

Loading…
Cancel
Save