exp to sql

This commit is contained in:
sunkaixuna
2021-12-24 21:33:08 +08:00
parent 8283209ea6
commit d7aafffca2
3 changed files with 84 additions and 8 deletions

View File

@@ -259,8 +259,8 @@ namespace OrmTest
var list2 = db.Queryable<Order>().Where(it =>
SqlFunc.Subqueryable<OrderItem>()
.LeftJoin<OrderItem>((i,y)=>i.ItemId==y.ItemId)
.InnerJoin<OrderItem>((i,z) => i.ItemId == z.ItemId)
.Where(i=>i.ItemId==1)
.InnerJoin<OrderItem>((i,y,z) => i.ItemId == z.ItemId)
.Where((i ,y)=>i.ItemId==1)
.Any()
).ToList();
;
@@ -276,6 +276,14 @@ namespace OrmTest
customName = SqlFunc.Subqueryable<Custom>().Where(exp).Where(exp).GroupBy(s => s.Name).Having(s => SqlFunc.AggregateCount(s.Id) > 0).Select(s => s.Name)
}).ToList();
var list5 = db.Queryable<Order>().Where(it =>
SqlFunc.Subqueryable<OrderItem>()
.LeftJoin<OrderItem>((i, y) => i.ItemId == y.ItemId)
.InnerJoin<OrderItem>((i, z) => i.ItemId == z.ItemId)
.Where(i => i.ItemId == 1)
.Any()
).ToList();
Console.WriteLine("#### Subquery End ####");
}

View File

@@ -6,21 +6,20 @@ using System.Text;
namespace SqlSugar
{
public class Subqueryable<T> where T : class, new()
public partial class Subqueryable<T> where T : class, new()
{
public Subqueryable<T> AS(string tableName)
{
return this;
}
public Subqueryable<T> InnerJoin<JoinType>(Func<T, JoinType, bool> expression)
public Subqueryable<T, JoinType> InnerJoin<JoinType>(Func<T, JoinType, bool> expression)
{
return this;
return new Subqueryable<T, JoinType>();
}
public Subqueryable<T> LeftJoin<JoinType>(Func<T, JoinType, bool> expression)
public Subqueryable<T, JoinType> LeftJoin<JoinType>(Func<T, JoinType, bool> expression)
{
return this;
return new Subqueryable<T, JoinType>();
}
public Subqueryable<T> Where(string where)

View File

@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public class Subqueryable<T, T2, T3, T4, T5> : Subqueryable<T> where T : class, new()
{
}
public class Subqueryable<T, T2, T3, T4> : Subqueryable<T> where T : class, new()
{
public Subqueryable<T, T2, T3, JoinType> InnerJoin<JoinType>(Func<T, T2, T3, JoinType, bool> expression)
{
return new Subqueryable<T, T2, T3, JoinType>();
}
public Subqueryable<T, T2, T3, JoinType> LeftJoin<JoinType>(Func<T, T2, T3, JoinType, bool> expression)
{
return new Subqueryable<T, T2, T3, JoinType>();
}
public Subqueryable<T, T2, T3, T4, JoinType> Where(Func<T, T2, T3, T4, bool> expression)
{
return new Subqueryable<T, T2, T3, T4, JoinType>();
}
public Subqueryable<T, T2, T3, T4, JoinType> Where(Func<T, T2, T3, bool> expression)
{
return new Subqueryable<T, T2, T3, T4, JoinType>();
}
public Subqueryable<T, T2, T3, T4, JoinType> Where(Func<T, T2, bool> expression)
{
return new Subqueryable<T, T2, T3, T4, JoinType>();
}
}
public class Subqueryable<T, T2, T3> : Subqueryable<T> where T : class, new()
{
public Subqueryable<T, T2, T3, JoinType> InnerJoin<JoinType>(Func<T, T2, T3, JoinType, bool> expression)
{
return new Subqueryable<T, T2, T3, JoinType>();
}
public Subqueryable<T, T2, T3, JoinType> LeftJoin<JoinType>(Func<T, T2, T3, JoinType, bool> expression)
{
return new Subqueryable<T, T2, T3, JoinType>();
}
public Subqueryable<T, T2, T3, JoinType> Where(Func<T, T2, T3, bool> expression)
{
return new Subqueryable<T, T2, T3, JoinType>();
}
public Subqueryable<T, T2, T3, JoinType> Where(Func<T, T2, bool> expression)
{
return new Subqueryable<T, T2, T3, JoinType>();
}
}
public class Subqueryable<T, T2> : Subqueryable<T> where T : class, new()
{
public Subqueryable<T, T2, JoinType> InnerJoin<JoinType>(Func<T, T2, JoinType, bool> expression)
{
return new Subqueryable<T, T2, JoinType>();
}
public Subqueryable<T, T2, JoinType> LeftJoin<JoinType>(Func<T, T2, JoinType, bool> expression)
{
return new Subqueryable<T, T2, JoinType>();
}
public Subqueryable<T, T2, JoinType> Where(Func<T, T2, bool> expression)
{
return new Subqueryable<T, T2, JoinType>();
}
}
}