Browse Source

Update exp to sql

pull/8/head
sunkaixuna 3 years ago
parent
commit
0046f6c3c9
  1. 7
      Src/Asp.Net/SqlServerTest/Demo/Demo1_Queryable.cs
  2. 7
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubAnd.cs
  3. 7
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubWhere.cs
  4. 4
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Subquerable.cs

7
Src/Asp.Net/SqlServerTest/Demo/Demo1_Queryable.cs

@ -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 ####");
}

7
Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubAnd.cs

@ -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;
}
}
}

7
Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubWhere.cs

@ -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;
}
}
}

4
Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Subquerable.cs

@ -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;

Loading…
Cancel
Save