Extend scoped typed select builder to deep join chains
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -122,5 +122,29 @@ namespace DynamORM.Tests.TypedSql
|
||||
"SELECT u.\"Id_User\" AS \"user_id\", d.\"Department_Name\" AS \"department_name\" FROM \"dbo\".\"Users\" AS u LEFT JOIN \"dbo\".\"UserClients\" AS c ON (u.\"Id_User\" = c.\"User_Id\") LEFT JOIN \"dbo\".\"UserRoles\" AS r ON (c.\"User_Id\" = r.\"User_Id\") LEFT JOIN \"dbo\".\"UserRegions\" AS g ON (r.\"User_Id\" = g.\"User_Id\") LEFT JOIN \"dbo\".\"UserDepartments\" AS d ON (g.\"Region_Id\" = d.\"Region_Id\") WHERE (d.\"Department_Id\" > [$0]) ORDER BY d.\"Department_Name\" ASC",
|
||||
NormalizeSql(cmd.CommandText()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestScopeBuilderSupportsTenTypedTables()
|
||||
{
|
||||
var cmd = Database.FromTypedScope<TypedFluentUser>("a")
|
||||
.Join<TypedFluentUser>(j => j.Left().As("b").OnSql((a, b) => a.Col(x => x.Id).Eq(b.Col(x => x.Id))))
|
||||
.Join<TypedFluentUser>(j => j.Left().As("c").OnSql((a, b, c) => b.Col(x => x.Id).Eq(c.Col(x => x.Id))))
|
||||
.Join<TypedFluentUser>(j => j.Left().As("d").OnSql((a, b, c, d) => c.Col(x => x.Id).Eq(d.Col(x => x.Id))))
|
||||
.Join<TypedFluentUser>(j => j.Left().As("e").OnSql((a, b, c, d, e) => d.Col(x => x.Id).Eq(e.Col(x => x.Id))))
|
||||
.Join<TypedFluentUser>(j => j.Left().As("f").OnSql((a, b, c, d, e, f) => e.Col(x => x.Id).Eq(f.Col(x => x.Id))))
|
||||
.Join<TypedFluentUser>(j => j.Left().As("g").OnSql((a, b, c, d, e, f, g) => f.Col(x => x.Id).Eq(g.Col(x => x.Id))))
|
||||
.Join<TypedFluentUser>(j => j.Left().As("h").OnSql((a, b, c, d, e, f, g, h) => g.Col(x => x.Id).Eq(h.Col(x => x.Id))))
|
||||
.Join<TypedFluentUser>(j => j.Left().As("i").OnSql((a, b, c, d, e, f, g, h, i) => h.Col(x => x.Id).Eq(i.Col(x => x.Id))))
|
||||
.Join<TypedFluentUser>(j => j.Left().As("j").OnSql((a, b, c, d, e, f, g, h, i, j) => i.Col(x => x.Id).Eq(j.Col(x => x.Id))))
|
||||
.SelectSql(
|
||||
(a, b, c, d, e, f, g, h, i, j) => a.Col(x => x.Id).As("root_id"),
|
||||
(a, b, c, d, e, f, g, h, i, j) => j.Col(x => x.Code).As("last_code"))
|
||||
.WhereSql((a, b, c, d, e, f, g, h, i, j) => j.Col(x => x.Code).IsNotNull())
|
||||
.OrderBySql((a, b, c, d, e, f, g, h, i, j) => j.Col(x => x.Code).Asc());
|
||||
|
||||
Assert.AreEqual(
|
||||
"SELECT a.\"id_user\" AS \"root_id\", j.\"user_code\" AS \"last_code\" FROM \"sample_users\" AS a LEFT JOIN \"sample_users\" AS b ON (a.\"id_user\" = b.\"id_user\") LEFT JOIN \"sample_users\" AS c ON (b.\"id_user\" = c.\"id_user\") LEFT JOIN \"sample_users\" AS d ON (c.\"id_user\" = d.\"id_user\") LEFT JOIN \"sample_users\" AS e ON (d.\"id_user\" = e.\"id_user\") LEFT JOIN \"sample_users\" AS f ON (e.\"id_user\" = f.\"id_user\") LEFT JOIN \"sample_users\" AS g ON (f.\"id_user\" = g.\"id_user\") LEFT JOIN \"sample_users\" AS h ON (g.\"id_user\" = h.\"id_user\") LEFT JOIN \"sample_users\" AS i ON (h.\"id_user\" = i.\"id_user\") LEFT JOIN \"sample_users\" AS j ON (i.\"id_user\" = j.\"id_user\") WHERE (j.\"user_code\" IS NOT NULL) ORDER BY j.\"user_code\" ASC",
|
||||
NormalizeSql(cmd.CommandText()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,18 +9,16 @@ using DynamORM.TypedSql;
|
||||
|
||||
namespace DynamORM.Builders
|
||||
{
|
||||
/// <summary>Typed scope-based select builder with evolving join arity.</summary>
|
||||
public interface IDynamicTypedSelectScopeQueryBuilder<T> : IDynamicSelectQueryBuilder
|
||||
public interface IDynamicTypedSelectScopeQueryBuilder<T1> : IDynamicSelectQueryBuilder
|
||||
{
|
||||
IDynamicTypedSelectScopeQueryBuilder<T, TJoin1> Join<TJoin1>(Func<TypedScopeJoinBuilder<T, TJoin1>, TypedScopeJoinBuilder<T, TJoin1>> specification);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T> SelectSql(Func<TypedTableContext<T>, TypedSqlSelectable> selector, params Func<TypedTableContext<T>, TypedSqlSelectable>[] selectors);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T> WhereSql(Func<TypedTableContext<T>, TypedSqlPredicate> predicate);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T> HavingSql(Func<TypedTableContext<T>, TypedSqlPredicate> predicate);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T> GroupBySql(Func<TypedTableContext<T>, TypedSqlExpression> selector, params Func<TypedTableContext<T>, TypedSqlExpression>[] selectors);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T> OrderBySql(Func<TypedTableContext<T>, TypedSqlOrderExpression> selector, params Func<TypedTableContext<T>, TypedSqlOrderExpression>[] selectors);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, TJoin2> Join<TJoin2>(Func<TypedScopeJoinBuilder<T1, TJoin2>, TypedScopeJoinBuilder<T1, TJoin2>> specification);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1> SelectSql(Func<TypedTableContext<T1>, TypedSqlSelectable> selector, params Func<TypedTableContext<T1>, TypedSqlSelectable>[] selectors);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1> WhereSql(Func<TypedTableContext<T1>, TypedSqlPredicate> predicate);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1> HavingSql(Func<TypedTableContext<T1>, TypedSqlPredicate> predicate);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1> GroupBySql(Func<TypedTableContext<T1>, TypedSqlExpression> selector, params Func<TypedTableContext<T1>, TypedSqlExpression>[] selectors);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1> OrderBySql(Func<TypedTableContext<T1>, TypedSqlOrderExpression> selector, params Func<TypedTableContext<T1>, TypedSqlOrderExpression>[] selectors);
|
||||
}
|
||||
|
||||
/// <summary>Typed scope-based select builder with two typed table contexts.</summary>
|
||||
public interface IDynamicTypedSelectScopeQueryBuilder<T1, T2> : IDynamicSelectQueryBuilder
|
||||
{
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, TJoin3> Join<TJoin3>(Func<TypedScopeJoinBuilder<T1, T2, TJoin3>, TypedScopeJoinBuilder<T1, T2, TJoin3>> specification);
|
||||
@@ -31,7 +29,6 @@ namespace DynamORM.Builders
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2> OrderBySql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedSqlOrderExpression> selector, params Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedSqlOrderExpression>[] selectors);
|
||||
}
|
||||
|
||||
/// <summary>Typed scope-based select builder with three typed table contexts.</summary>
|
||||
public interface IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3> : IDynamicSelectQueryBuilder
|
||||
{
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, TJoin4> Join<TJoin4>(Func<TypedScopeJoinBuilder<T1, T2, T3, TJoin4>, TypedScopeJoinBuilder<T1, T2, T3, TJoin4>> specification);
|
||||
@@ -42,7 +39,6 @@ namespace DynamORM.Builders
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3> OrderBySql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedSqlOrderExpression> selector, params Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedSqlOrderExpression>[] selectors);
|
||||
}
|
||||
|
||||
/// <summary>Typed scope-based select builder with four typed table contexts.</summary>
|
||||
public interface IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4> : IDynamicSelectQueryBuilder
|
||||
{
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, TJoin5> Join<TJoin5>(Func<TypedScopeJoinBuilder<T1, T2, T3, T4, TJoin5>, TypedScopeJoinBuilder<T1, T2, T3, T4, TJoin5>> specification);
|
||||
@@ -53,13 +49,63 @@ namespace DynamORM.Builders
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4> OrderBySql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedSqlOrderExpression> selector, params Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedSqlOrderExpression>[] selectors);
|
||||
}
|
||||
|
||||
/// <summary>Typed scope-based select builder with five typed table contexts.</summary>
|
||||
public interface IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5> : IDynamicSelectQueryBuilder
|
||||
{
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, TJoin6> Join<TJoin6>(Func<TypedScopeJoinBuilder<T1, T2, T3, T4, T5, TJoin6>, TypedScopeJoinBuilder<T1, T2, T3, T4, T5, TJoin6>> specification);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5> SelectSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedSqlSelectable> selector, params Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedSqlSelectable>[] selectors);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5> WhereSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedSqlPredicate> predicate);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5> HavingSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedSqlPredicate> predicate);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5> GroupBySql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedSqlExpression> selector, params Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedSqlExpression>[] selectors);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5> OrderBySql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedSqlOrderExpression> selector, params Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedSqlOrderExpression>[] selectors);
|
||||
}
|
||||
|
||||
public interface IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6> : IDynamicSelectQueryBuilder
|
||||
{
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, TJoin7> Join<TJoin7>(Func<TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, TJoin7>, TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, TJoin7>> specification);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6> SelectSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedSqlSelectable> selector, params Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedSqlSelectable>[] selectors);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6> WhereSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedSqlPredicate> predicate);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6> HavingSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedSqlPredicate> predicate);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6> GroupBySql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedSqlExpression> selector, params Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedSqlExpression>[] selectors);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6> OrderBySql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedSqlOrderExpression> selector, params Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedSqlOrderExpression>[] selectors);
|
||||
}
|
||||
|
||||
public interface IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7> : IDynamicSelectQueryBuilder
|
||||
{
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7, TJoin8> Join<TJoin8>(Func<TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, T7, TJoin8>, TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, T7, TJoin8>> specification);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7> SelectSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedSqlSelectable> selector, params Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedSqlSelectable>[] selectors);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7> WhereSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedSqlPredicate> predicate);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7> HavingSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedSqlPredicate> predicate);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7> GroupBySql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedSqlExpression> selector, params Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedSqlExpression>[] selectors);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7> OrderBySql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedSqlOrderExpression> selector, params Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedSqlOrderExpression>[] selectors);
|
||||
}
|
||||
|
||||
public interface IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7, T8> : IDynamicSelectQueryBuilder
|
||||
{
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7, T8, TJoin9> Join<TJoin9>(Func<TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, T7, T8, TJoin9>, TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, T7, T8, TJoin9>> specification);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7, T8> SelectSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedSqlSelectable> selector, params Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedSqlSelectable>[] selectors);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7, T8> WhereSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedSqlPredicate> predicate);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7, T8> HavingSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedSqlPredicate> predicate);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7, T8> GroupBySql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedSqlExpression> selector, params Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedSqlExpression>[] selectors);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7, T8> OrderBySql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedSqlOrderExpression> selector, params Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedSqlOrderExpression>[] selectors);
|
||||
}
|
||||
|
||||
public interface IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9> : IDynamicSelectQueryBuilder
|
||||
{
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, TJoin10> Join<TJoin10>(Func<TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, TJoin10>, TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, TJoin10>> specification);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9> SelectSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedTableContext<T9>, TypedSqlSelectable> selector, params Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedTableContext<T9>, TypedSqlSelectable>[] selectors);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9> WhereSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedTableContext<T9>, TypedSqlPredicate> predicate);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9> HavingSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedTableContext<T9>, TypedSqlPredicate> predicate);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9> GroupBySql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedTableContext<T9>, TypedSqlExpression> selector, params Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedTableContext<T9>, TypedSqlExpression>[] selectors);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9> OrderBySql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedTableContext<T9>, TypedSqlOrderExpression> selector, params Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedTableContext<T9>, TypedSqlOrderExpression>[] selectors);
|
||||
}
|
||||
|
||||
public interface IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> : IDynamicSelectQueryBuilder
|
||||
{
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> SelectSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedTableContext<T9>, TypedTableContext<T10>, TypedSqlSelectable> selector, params Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedTableContext<T9>, TypedTableContext<T10>, TypedSqlSelectable>[] selectors);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> WhereSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedTableContext<T9>, TypedTableContext<T10>, TypedSqlPredicate> predicate);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> HavingSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedTableContext<T9>, TypedTableContext<T10>, TypedSqlPredicate> predicate);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> GroupBySql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedTableContext<T9>, TypedTableContext<T10>, TypedSqlExpression> selector, params Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedTableContext<T9>, TypedTableContext<T10>, TypedSqlExpression>[] selectors);
|
||||
IDynamicTypedSelectScopeQueryBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> OrderBySql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedTableContext<T9>, TypedTableContext<T10>, TypedSqlOrderExpression> selector, params Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedTableContext<T9>, TypedTableContext<T10>, TypedSqlOrderExpression>[] selectors);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -678,7 +678,7 @@ namespace DynamORM.Builders.Implementation
|
||||
AddSelectSqlSelector(selector(GetRootContext()));
|
||||
}
|
||||
|
||||
private void AddSelectSqlSelector(TypedSqlSelectable item)
|
||||
internal void AddSelectSqlSelector(TypedSqlSelectable item)
|
||||
{
|
||||
if (item == null)
|
||||
throw new ArgumentNullException("item");
|
||||
@@ -715,7 +715,7 @@ namespace DynamORM.Builders.Implementation
|
||||
AddGroupBySqlSelector(selector(GetRootContext()));
|
||||
}
|
||||
|
||||
private void AddGroupBySqlSelector(TypedSqlExpression item)
|
||||
internal void AddGroupBySqlSelector(TypedSqlExpression item)
|
||||
{
|
||||
if (item == null)
|
||||
throw new ArgumentNullException("item");
|
||||
@@ -749,7 +749,7 @@ namespace DynamORM.Builders.Implementation
|
||||
AddOrderBySqlSelector(selector(GetRootContext()));
|
||||
}
|
||||
|
||||
private void AddOrderBySqlSelector(TypedSqlOrderExpression item)
|
||||
internal void AddOrderBySqlSelector(TypedSqlOrderExpression item)
|
||||
{
|
||||
TypedSqlRenderContext context = new TypedSqlRenderContext(this);
|
||||
string rendered = item.Render(context);
|
||||
@@ -976,7 +976,7 @@ namespace DynamORM.Builders.Implementation
|
||||
});
|
||||
}
|
||||
|
||||
private void AppendSqlCondition(string condition, bool having)
|
||||
internal void AppendSqlCondition(string condition, bool having)
|
||||
{
|
||||
if (having)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,16 +12,9 @@ namespace DynamORM.Builders
|
||||
public abstract class TypedScopeJoinBuilderBase<TSelf>
|
||||
where TSelf : TypedScopeJoinBuilderBase<TSelf>
|
||||
{
|
||||
/// <summary>Gets join alias.</summary>
|
||||
public string Alias { get; private set; }
|
||||
|
||||
/// <summary>Gets join type.</summary>
|
||||
public DynamicJoinType JoinType { get; private set; }
|
||||
|
||||
/// <summary>Gets custom join type text.</summary>
|
||||
public string CustomJoinType { get; private set; }
|
||||
|
||||
/// <summary>Gets a value indicating whether joined source should use NOLOCK.</summary>
|
||||
public bool UseNoLock { get; private set; }
|
||||
|
||||
protected TypedScopeJoinBuilderBase()
|
||||
@@ -35,67 +28,19 @@ namespace DynamORM.Builders
|
||||
return (TSelf)this;
|
||||
}
|
||||
|
||||
public TSelf Inner()
|
||||
{
|
||||
JoinType = DynamicJoinType.Inner;
|
||||
CustomJoinType = null;
|
||||
return (TSelf)this;
|
||||
}
|
||||
|
||||
public TSelf Join()
|
||||
{
|
||||
JoinType = DynamicJoinType.Join;
|
||||
CustomJoinType = null;
|
||||
return (TSelf)this;
|
||||
}
|
||||
|
||||
public TSelf Left()
|
||||
{
|
||||
JoinType = DynamicJoinType.Left;
|
||||
CustomJoinType = null;
|
||||
return (TSelf)this;
|
||||
}
|
||||
|
||||
public TSelf Right()
|
||||
{
|
||||
JoinType = DynamicJoinType.Right;
|
||||
CustomJoinType = null;
|
||||
return (TSelf)this;
|
||||
}
|
||||
|
||||
public TSelf Full()
|
||||
{
|
||||
JoinType = DynamicJoinType.Full;
|
||||
CustomJoinType = null;
|
||||
return (TSelf)this;
|
||||
}
|
||||
|
||||
public TSelf LeftOuter()
|
||||
{
|
||||
JoinType = DynamicJoinType.LeftOuter;
|
||||
CustomJoinType = null;
|
||||
return (TSelf)this;
|
||||
}
|
||||
|
||||
public TSelf RightOuter()
|
||||
{
|
||||
JoinType = DynamicJoinType.RightOuter;
|
||||
CustomJoinType = null;
|
||||
return (TSelf)this;
|
||||
}
|
||||
|
||||
public TSelf FullOuter()
|
||||
{
|
||||
JoinType = DynamicJoinType.FullOuter;
|
||||
CustomJoinType = null;
|
||||
return (TSelf)this;
|
||||
}
|
||||
public TSelf Inner() { JoinType = DynamicJoinType.Inner; CustomJoinType = null; return (TSelf)this; }
|
||||
public TSelf Join() { JoinType = DynamicJoinType.Join; CustomJoinType = null; return (TSelf)this; }
|
||||
public TSelf Left() { JoinType = DynamicJoinType.Left; CustomJoinType = null; return (TSelf)this; }
|
||||
public TSelf Right() { JoinType = DynamicJoinType.Right; CustomJoinType = null; return (TSelf)this; }
|
||||
public TSelf Full() { JoinType = DynamicJoinType.Full; CustomJoinType = null; return (TSelf)this; }
|
||||
public TSelf LeftOuter() { JoinType = DynamicJoinType.LeftOuter; CustomJoinType = null; return (TSelf)this; }
|
||||
public TSelf RightOuter() { JoinType = DynamicJoinType.RightOuter; CustomJoinType = null; return (TSelf)this; }
|
||||
public TSelf FullOuter() { JoinType = DynamicJoinType.FullOuter; CustomJoinType = null; return (TSelf)this; }
|
||||
|
||||
public TSelf Type(string joinType)
|
||||
{
|
||||
if (string.IsNullOrEmpty(joinType))
|
||||
throw new ArgumentNullException("joinType");
|
||||
|
||||
CustomJoinType = joinType.Trim();
|
||||
return (TSelf)this;
|
||||
}
|
||||
@@ -116,7 +61,6 @@ namespace DynamORM.Builders
|
||||
{
|
||||
if (predicate == null)
|
||||
throw new ArgumentNullException("predicate");
|
||||
|
||||
OnSqlPredicate = predicate;
|
||||
OnRawCondition = null;
|
||||
return this;
|
||||
@@ -126,7 +70,6 @@ namespace DynamORM.Builders
|
||||
{
|
||||
if (string.IsNullOrEmpty(condition))
|
||||
throw new ArgumentNullException("condition");
|
||||
|
||||
OnRawCondition = condition.Trim();
|
||||
OnSqlPredicate = null;
|
||||
return this;
|
||||
@@ -142,7 +85,6 @@ namespace DynamORM.Builders
|
||||
{
|
||||
if (predicate == null)
|
||||
throw new ArgumentNullException("predicate");
|
||||
|
||||
OnSqlPredicate = predicate;
|
||||
OnRawCondition = null;
|
||||
return this;
|
||||
@@ -152,7 +94,6 @@ namespace DynamORM.Builders
|
||||
{
|
||||
if (string.IsNullOrEmpty(condition))
|
||||
throw new ArgumentNullException("condition");
|
||||
|
||||
OnRawCondition = condition.Trim();
|
||||
OnSqlPredicate = null;
|
||||
return this;
|
||||
@@ -168,7 +109,6 @@ namespace DynamORM.Builders
|
||||
{
|
||||
if (predicate == null)
|
||||
throw new ArgumentNullException("predicate");
|
||||
|
||||
OnSqlPredicate = predicate;
|
||||
OnRawCondition = null;
|
||||
return this;
|
||||
@@ -178,7 +118,6 @@ namespace DynamORM.Builders
|
||||
{
|
||||
if (string.IsNullOrEmpty(condition))
|
||||
throw new ArgumentNullException("condition");
|
||||
|
||||
OnRawCondition = condition.Trim();
|
||||
OnSqlPredicate = null;
|
||||
return this;
|
||||
@@ -194,7 +133,6 @@ namespace DynamORM.Builders
|
||||
{
|
||||
if (predicate == null)
|
||||
throw new ArgumentNullException("predicate");
|
||||
|
||||
OnSqlPredicate = predicate;
|
||||
OnRawCondition = null;
|
||||
return this;
|
||||
@@ -204,10 +142,130 @@ namespace DynamORM.Builders
|
||||
{
|
||||
if (string.IsNullOrEmpty(condition))
|
||||
throw new ArgumentNullException("condition");
|
||||
|
||||
OnRawCondition = condition.Trim();
|
||||
OnSqlPredicate = null;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class TypedScopeJoinBuilder<T1, T2, T3, T4, T5, TRight> : TypedScopeJoinBuilderBase<TypedScopeJoinBuilder<T1, T2, T3, T4, T5, TRight>>
|
||||
{
|
||||
internal Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<TRight>, TypedSqlPredicate> OnSqlPredicate { get; private set; }
|
||||
internal string OnRawCondition { get; private set; }
|
||||
|
||||
public TypedScopeJoinBuilder<T1, T2, T3, T4, T5, TRight> OnSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<TRight>, TypedSqlPredicate> predicate)
|
||||
{
|
||||
if (predicate == null)
|
||||
throw new ArgumentNullException("predicate");
|
||||
OnSqlPredicate = predicate;
|
||||
OnRawCondition = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TypedScopeJoinBuilder<T1, T2, T3, T4, T5, TRight> OnRaw(string condition)
|
||||
{
|
||||
if (string.IsNullOrEmpty(condition))
|
||||
throw new ArgumentNullException("condition");
|
||||
OnRawCondition = condition.Trim();
|
||||
OnSqlPredicate = null;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, TRight> : TypedScopeJoinBuilderBase<TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, TRight>>
|
||||
{
|
||||
internal Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<TRight>, TypedSqlPredicate> OnSqlPredicate { get; private set; }
|
||||
internal string OnRawCondition { get; private set; }
|
||||
|
||||
public TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, TRight> OnSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<TRight>, TypedSqlPredicate> predicate)
|
||||
{
|
||||
if (predicate == null)
|
||||
throw new ArgumentNullException("predicate");
|
||||
OnSqlPredicate = predicate;
|
||||
OnRawCondition = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, TRight> OnRaw(string condition)
|
||||
{
|
||||
if (string.IsNullOrEmpty(condition))
|
||||
throw new ArgumentNullException("condition");
|
||||
OnRawCondition = condition.Trim();
|
||||
OnSqlPredicate = null;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, T7, TRight> : TypedScopeJoinBuilderBase<TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, T7, TRight>>
|
||||
{
|
||||
internal Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<TRight>, TypedSqlPredicate> OnSqlPredicate { get; private set; }
|
||||
internal string OnRawCondition { get; private set; }
|
||||
|
||||
public TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, T7, TRight> OnSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<TRight>, TypedSqlPredicate> predicate)
|
||||
{
|
||||
if (predicate == null)
|
||||
throw new ArgumentNullException("predicate");
|
||||
OnSqlPredicate = predicate;
|
||||
OnRawCondition = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, T7, TRight> OnRaw(string condition)
|
||||
{
|
||||
if (string.IsNullOrEmpty(condition))
|
||||
throw new ArgumentNullException("condition");
|
||||
OnRawCondition = condition.Trim();
|
||||
OnSqlPredicate = null;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, T7, T8, TRight> : TypedScopeJoinBuilderBase<TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, T7, T8, TRight>>
|
||||
{
|
||||
internal Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedTableContext<TRight>, TypedSqlPredicate> OnSqlPredicate { get; private set; }
|
||||
internal string OnRawCondition { get; private set; }
|
||||
|
||||
public TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, T7, T8, TRight> OnSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedTableContext<TRight>, TypedSqlPredicate> predicate)
|
||||
{
|
||||
if (predicate == null)
|
||||
throw new ArgumentNullException("predicate");
|
||||
OnSqlPredicate = predicate;
|
||||
OnRawCondition = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, T7, T8, TRight> OnRaw(string condition)
|
||||
{
|
||||
if (string.IsNullOrEmpty(condition))
|
||||
throw new ArgumentNullException("condition");
|
||||
OnRawCondition = condition.Trim();
|
||||
OnSqlPredicate = null;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, TRight> : TypedScopeJoinBuilderBase<TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, TRight>>
|
||||
{
|
||||
internal Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedTableContext<T9>, TypedTableContext<TRight>, TypedSqlPredicate> OnSqlPredicate { get; private set; }
|
||||
internal string OnRawCondition { get; private set; }
|
||||
|
||||
public TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, TRight> OnSql(Func<TypedTableContext<T1>, TypedTableContext<T2>, TypedTableContext<T3>, TypedTableContext<T4>, TypedTableContext<T5>, TypedTableContext<T6>, TypedTableContext<T7>, TypedTableContext<T8>, TypedTableContext<T9>, TypedTableContext<TRight>, TypedSqlPredicate> predicate)
|
||||
{
|
||||
if (predicate == null)
|
||||
throw new ArgumentNullException("predicate");
|
||||
OnSqlPredicate = predicate;
|
||||
OnRawCondition = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TypedScopeJoinBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, TRight> OnRaw(string condition)
|
||||
{
|
||||
if (string.IsNullOrEmpty(condition))
|
||||
throw new ArgumentNullException("condition");
|
||||
OnRawCondition = condition.Trim();
|
||||
OnSqlPredicate = null;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user