mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 13:06:50 +08:00
Update exp to sql
This commit is contained in:
parent
d603994ac6
commit
d26327a39f
@ -102,6 +102,21 @@ namespace OrmTest
|
|||||||
a = string.IsNullOrEmpty(it.Name)
|
a = string.IsNullOrEmpty(it.Name)
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
|
var blist4 = Db.Queryable<BoolTest3>().Select(it => new BoolTest3()
|
||||||
|
{
|
||||||
|
a = SqlFunc.IIF(it.a == true, true, false)
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
var blist5 = Db.Queryable<BoolTest3>().Select(it => new BoolTest3()
|
||||||
|
{
|
||||||
|
a = SqlFunc.IF(it.a == true).Return(true).End(false)
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
var blist6 = Db.Queryable<BoolTest3>().Select(it => new BoolTest3()
|
||||||
|
{
|
||||||
|
a =it.a==true?true:false
|
||||||
|
}).ToList();
|
||||||
var db = Db;
|
var db = Db;
|
||||||
db.CodeFirst.InitTables<UserInfo, UserIpRuleInfo>();
|
db.CodeFirst.InitTables<UserInfo, UserIpRuleInfo>();
|
||||||
db.Deleteable<UserInfo>().ExecuteCommand();
|
db.Deleteable<UserInfo>().ExecuteCommand();
|
||||||
|
@ -477,19 +477,19 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
asName = GetAsNameAndShortName(item, shortName, property);
|
asName = GetAsNameAndShortName(item, shortName, property);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
asName = GetAsName(item, shortName, property);
|
asName = GetAsName(item, shortName, property);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (item.Type == UtilConstants.BoolType && item is MethodCallExpression)
|
else if (item.Type == UtilConstants.BoolType && item is MethodCallExpression && IsNotCaseExpression(item))
|
||||||
{
|
{
|
||||||
this.Expression = item;
|
this.Expression = item;
|
||||||
this.Start();
|
this.Start();
|
||||||
var sql= this.Context.DbMehtods.IIF(new MethodCallExpressionModel()
|
var sql= this.Context.DbMehtods.IIF(new MethodCallExpressionModel()
|
||||||
{
|
{
|
||||||
Args=new List<MethodCallExpressionArgs>() {
|
Args=new List<MethodCallExpressionArgs>() {
|
||||||
new MethodCallExpressionArgs() {
|
new MethodCallExpressionArgs() {
|
||||||
IsMember=true,
|
IsMember=true,
|
||||||
MemberName=parameter.CommonTempData.ObjToString()
|
MemberName=parameter.CommonTempData.ObjToString()
|
||||||
@ -518,6 +518,22 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool IsNotCaseExpression(Expression item)
|
||||||
|
{
|
||||||
|
if ((item as MethodCallExpression).Method.Name == "IIF")
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if ((item as MethodCallExpression).Method.Name == "End"&&item.ToString().Contains("IF("))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Dictionary<string, string> GetMappingColumns(Expression currentExpression)
|
private Dictionary<string, string> GetMappingColumns(Expression currentExpression)
|
||||||
{
|
{
|
||||||
Dictionary<string, string> result = new Dictionary<string, string>();
|
Dictionary<string, string> result = new Dictionary<string, string>();
|
||||||
|
Loading…
Reference in New Issue
Block a user