mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-24 04:53:45 +08:00
Update exp to sql
This commit is contained in:
@@ -249,6 +249,13 @@ namespace OrmTest
|
||||
customName = SqlFunc.Subqueryable<Custom>().Where(s=>s.Id==it.CustomId).GroupBy(s=>s.Name).Having(s=>SqlFunc.AggregateCount(s.Id)>0).Select(s => s.Name)
|
||||
}).ToList();
|
||||
|
||||
|
||||
var exp = Expressionable.Create<Custom>().And(s => s.Id==1).ToExpression();
|
||||
var list4 = db.Queryable<Order>().Select(it => new
|
||||
{
|
||||
customName = SqlFunc.Subqueryable<Custom>().Where(exp).GroupBy(s => s.Name).Having(s => SqlFunc.AggregateCount(s.Id) > 0).Select(s => s.Name)
|
||||
}).ToList();
|
||||
|
||||
Console.WriteLine("#### Subquery End ####");
|
||||
}
|
||||
|
||||
|
@@ -55,7 +55,7 @@ namespace SqlSugar
|
||||
}
|
||||
if (Regex.IsMatch(result, regex))
|
||||
{
|
||||
result = "AND " + this.Context.Parameters.First(it => it.ParameterName == Regex.Match(result, regex).Groups[1].Value).Value;
|
||||
result = "AND " + GetValue(result, regex);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -64,5 +64,10 @@ namespace SqlSugar
|
||||
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
|
||||
return result;
|
||||
}
|
||||
|
||||
private object GetValue(string result, string regex)
|
||||
{
|
||||
return this.Context.Parameters.First(it => it.ParameterName == Regex.Match(result, regex).Groups[1].Value).Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -55,7 +55,7 @@ namespace SqlSugar
|
||||
}
|
||||
if (Regex.IsMatch(result, regex))
|
||||
{
|
||||
result = "WHERE " + this.Context.Parameters.First(it => it.ParameterName == Regex.Match(result, regex).Groups[1].Value).Value;
|
||||
result = "WHERE " + GetValue(result, regex);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -64,5 +64,10 @@ namespace SqlSugar
|
||||
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
|
||||
return result;
|
||||
}
|
||||
|
||||
private object GetValue(string result, string regex)
|
||||
{
|
||||
return this.Context.Parameters.First(it => it.ParameterName == Regex.Match(result, regex).Groups[1].Value).Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -27,6 +27,10 @@ namespace SqlSugar
|
||||
{
|
||||
return this;
|
||||
}
|
||||
public Subqueryable<T> Where(Expression exp)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
public Subqueryable<T> Where(Func<T, bool> expression)
|
||||
{
|
||||
return this;
|
||||
|
Reference in New Issue
Block a user