diff --git a/FreeSql/FreeSql.csproj b/FreeSql/FreeSql.csproj index 401f7500..70dcaf2e 100644 --- a/FreeSql/FreeSql.csproj +++ b/FreeSql/FreeSql.csproj @@ -24,6 +24,10 @@ + + + + FreeSql.xml diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select10Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select10Provider.cs index dbd36784..b6f190b8 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select10Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select10Provider.cs @@ -32,6 +32,7 @@ namespace FreeSql.Internal.CommonProvider { this.AsTable((type, old) => { + if (type == _tables[0].Table?.Type && string.IsNullOrEmpty(sqlT1) == false) return $"({sqlT1})"; if (type == _tables[1].Table?.Type && string.IsNullOrEmpty(sqlT2) == false) return $"({sqlT2})"; if (type == _tables[2].Table?.Type && string.IsNullOrEmpty(sqlT3) == false) return $"({sqlT3})"; if (type == _tables[3].Table?.Type && string.IsNullOrEmpty(sqlT4) == false) return $"({sqlT4})"; @@ -44,7 +45,7 @@ namespace FreeSql.Internal.CommonProvider return old; }); - if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6};\r\n{sqlT7};\r\n{sqlT8};\r\n{sqlT9};\r\n{sqlT10};", parms)); + if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT1};\r\n{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6};\r\n{sqlT7};\r\n{sqlT8};\r\n{sqlT9};\r\n{sqlT10}", parms)); return this; } @@ -235,61 +236,61 @@ namespace FreeSql.Internal.CommonProvider TMember ISelect.Min(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Min((Expression>)expModify); + return (this as ISelect).Min((Expression>)expModify); } ISelect ISelect.OrderBy(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderBy((Expression>)expModify); + return (this as ISelect).OrderBy((Expression>)expModify); } ISelect ISelect.OrderByDescending(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByDescending((Expression>)expModify); + return (this as ISelect).OrderByDescending((Expression>)expModify); } ISelect ISelect.OrderByIf(bool condition, Expression, TMember>> column, bool descending) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); + return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); } decimal ISelect.Sum(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Sum((Expression>)expModify); + return (this as ISelect).Sum((Expression>)expModify); } List ISelect.ToList(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToList((Expression>)expModify); + return (this as ISelect).ToList((Expression>)expModify); } public void ToChunk(Expression, TReturn>> select, int size, Action>> done) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - (this as ISelect).ToChunk((Expression>)expModify, size, done); + (this as ISelect).ToChunk((Expression>)expModify, size, done); } DataTable ISelect.ToDataTable(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTable((Expression>)expModify); + return (this as ISelect).ToDataTable((Expression>)expModify); } int ISelect.InsertInto(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertInto(tableName, (Expression>)expModify); + return (this as ISelect).InsertInto(tableName, (Expression>)expModify); } string ISelect.ToSql(Expression, TReturn>> select, FieldAliasOptions fieldAlias) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); + return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); } ISelect ISelect.LeftJoin(Expression, bool>> exp) @@ -418,43 +419,43 @@ namespace FreeSql.Internal.CommonProvider Task ISelect.AvgAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).AvgAsync((Expression>)expModify); + return (this as ISelect).AvgAsync((Expression>)expModify); } Task ISelect.MaxAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MaxAsync((Expression>)expModify); + return (this as ISelect).MaxAsync((Expression>)expModify); } Task ISelect.MinAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MinAsync((Expression>)expModify); + return (this as ISelect).MinAsync((Expression>)expModify); } Task ISelect.SumAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).SumAsync((Expression>)expModify); + return (this as ISelect).SumAsync((Expression>)expModify); } Task> ISelect.ToListAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToListAsync((Expression>)expModify); + return (this as ISelect).ToListAsync((Expression>)expModify); } Task ISelect.ToDataTableAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTableAsync((Expression>)expModify); + return (this as ISelect).ToDataTableAsync((Expression>)expModify); } Task ISelect.InsertIntoAsync(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); + return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); } async Task ISelect.AnyAsync(Expression, bool>> exp) @@ -475,4 +476,6 @@ namespace FreeSql.Internal.CommonProvider } + + } \ No newline at end of file diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select11Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select11Provider.cs index 59a549dd..5f58506a 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select11Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select11Provider.cs @@ -33,6 +33,7 @@ namespace FreeSql.Internal.CommonProvider { this.AsTable((type, old) => { + if (type == _tables[0].Table?.Type && string.IsNullOrEmpty(sqlT1) == false) return $"({sqlT1})"; if (type == _tables[1].Table?.Type && string.IsNullOrEmpty(sqlT2) == false) return $"({sqlT2})"; if (type == _tables[2].Table?.Type && string.IsNullOrEmpty(sqlT3) == false) return $"({sqlT3})"; if (type == _tables[3].Table?.Type && string.IsNullOrEmpty(sqlT4) == false) return $"({sqlT4})"; @@ -46,7 +47,7 @@ namespace FreeSql.Internal.CommonProvider return old; }); - if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6};\r\n{sqlT7};\r\n{sqlT8};\r\n{sqlT9};\r\n{sqlT10};\r\n{sqlT11};", parms)); + if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT1};\r\n{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6};\r\n{sqlT7};\r\n{sqlT8};\r\n{sqlT9};\r\n{sqlT10};\r\n{sqlT11}", parms)); return this; } @@ -237,61 +238,61 @@ namespace FreeSql.Internal.CommonProvider TMember ISelect.Min(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Min((Expression>)expModify); + return (this as ISelect).Min((Expression>)expModify); } ISelect ISelect.OrderBy(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderBy((Expression>)expModify); + return (this as ISelect).OrderBy((Expression>)expModify); } ISelect ISelect.OrderByDescending(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByDescending((Expression>)expModify); + return (this as ISelect).OrderByDescending((Expression>)expModify); } ISelect ISelect.OrderByIf(bool condition, Expression, TMember>> column, bool descending) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); + return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); } decimal ISelect.Sum(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Sum((Expression>)expModify); + return (this as ISelect).Sum((Expression>)expModify); } List ISelect.ToList(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToList((Expression>)expModify); + return (this as ISelect).ToList((Expression>)expModify); } public void ToChunk(Expression, TReturn>> select, int size, Action>> done) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - (this as ISelect).ToChunk((Expression>)expModify, size, done); + (this as ISelect).ToChunk((Expression>)expModify, size, done); } DataTable ISelect.ToDataTable(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTable((Expression>)expModify); + return (this as ISelect).ToDataTable((Expression>)expModify); } int ISelect.InsertInto(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertInto(tableName, (Expression>)expModify); + return (this as ISelect).InsertInto(tableName, (Expression>)expModify); } string ISelect.ToSql(Expression, TReturn>> select, FieldAliasOptions fieldAlias) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); + return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); } ISelect ISelect.LeftJoin(Expression, bool>> exp) @@ -420,43 +421,43 @@ namespace FreeSql.Internal.CommonProvider Task ISelect.AvgAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).AvgAsync((Expression>)expModify); + return (this as ISelect).AvgAsync((Expression>)expModify); } Task ISelect.MaxAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MaxAsync((Expression>)expModify); + return (this as ISelect).MaxAsync((Expression>)expModify); } Task ISelect.MinAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MinAsync((Expression>)expModify); + return (this as ISelect).MinAsync((Expression>)expModify); } Task ISelect.SumAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).SumAsync((Expression>)expModify); + return (this as ISelect).SumAsync((Expression>)expModify); } Task> ISelect.ToListAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToListAsync((Expression>)expModify); + return (this as ISelect).ToListAsync((Expression>)expModify); } Task ISelect.ToDataTableAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTableAsync((Expression>)expModify); + return (this as ISelect).ToDataTableAsync((Expression>)expModify); } Task ISelect.InsertIntoAsync(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); + return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); } async Task ISelect.AnyAsync(Expression, bool>> exp) @@ -476,5 +477,4 @@ namespace FreeSql.Internal.CommonProvider #endif } - } \ No newline at end of file diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select12Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select12Provider.cs index c9e0e016..282edd57 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select12Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select12Provider.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; namespace FreeSql.Internal.CommonProvider { - public abstract class Select12Provider : Select0Provider, T1>, ISelect where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class { @@ -35,6 +34,7 @@ namespace FreeSql.Internal.CommonProvider { this.AsTable((type, old) => { + if (type == _tables[0].Table?.Type && string.IsNullOrEmpty(sqlT1) == false) return $"({sqlT1})"; if (type == _tables[1].Table?.Type && string.IsNullOrEmpty(sqlT2) == false) return $"({sqlT2})"; if (type == _tables[2].Table?.Type && string.IsNullOrEmpty(sqlT3) == false) return $"({sqlT3})"; if (type == _tables[3].Table?.Type && string.IsNullOrEmpty(sqlT4) == false) return $"({sqlT4})"; @@ -49,7 +49,7 @@ namespace FreeSql.Internal.CommonProvider return old; }); - if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6};\r\n{sqlT7};\r\n{sqlT8};\r\n{sqlT9};\r\n{sqlT10};\r\n{sqlT11};\r\n{sqlT12};", parms)); + if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT1};\r\n{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6};\r\n{sqlT7};\r\n{sqlT8};\r\n{sqlT9};\r\n{sqlT10};\r\n{sqlT11};\r\n{sqlT12}", parms)); return this; } @@ -240,61 +240,61 @@ namespace FreeSql.Internal.CommonProvider TMember ISelect.Min(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Min((Expression>)expModify); + return (this as ISelect).Min((Expression>)expModify); } ISelect ISelect.OrderBy(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderBy((Expression>)expModify); + return (this as ISelect).OrderBy((Expression>)expModify); } ISelect ISelect.OrderByDescending(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByDescending((Expression>)expModify); + return (this as ISelect).OrderByDescending((Expression>)expModify); } ISelect ISelect.OrderByIf(bool condition, Expression, TMember>> column, bool descending) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); + return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); } decimal ISelect.Sum(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Sum((Expression>)expModify); + return (this as ISelect).Sum((Expression>)expModify); } List ISelect.ToList(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToList((Expression>)expModify); + return (this as ISelect).ToList((Expression>)expModify); } public void ToChunk(Expression, TReturn>> select, int size, Action>> done) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - (this as ISelect).ToChunk((Expression>)expModify, size, done); + (this as ISelect).ToChunk((Expression>)expModify, size, done); } DataTable ISelect.ToDataTable(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTable((Expression>)expModify); + return (this as ISelect).ToDataTable((Expression>)expModify); } int ISelect.InsertInto(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertInto(tableName, (Expression>)expModify); + return (this as ISelect).InsertInto(tableName, (Expression>)expModify); } string ISelect.ToSql(Expression, TReturn>> select, FieldAliasOptions fieldAlias) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); + return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); } ISelect ISelect.LeftJoin(Expression, bool>> exp) @@ -423,43 +423,43 @@ namespace FreeSql.Internal.CommonProvider Task ISelect.AvgAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).AvgAsync((Expression>)expModify); + return (this as ISelect).AvgAsync((Expression>)expModify); } Task ISelect.MaxAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MaxAsync((Expression>)expModify); + return (this as ISelect).MaxAsync((Expression>)expModify); } Task ISelect.MinAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MinAsync((Expression>)expModify); + return (this as ISelect).MinAsync((Expression>)expModify); } Task ISelect.SumAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).SumAsync((Expression>)expModify); + return (this as ISelect).SumAsync((Expression>)expModify); } Task> ISelect.ToListAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToListAsync((Expression>)expModify); + return (this as ISelect).ToListAsync((Expression>)expModify); } Task ISelect.ToDataTableAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTableAsync((Expression>)expModify); + return (this as ISelect).ToDataTableAsync((Expression>)expModify); } Task ISelect.InsertIntoAsync(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); + return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); } async Task ISelect.AnyAsync(Expression, bool>> exp) diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select13Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select13Provider.cs index 2d3d691e..e89ef83d 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select13Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select13Provider.cs @@ -35,6 +35,7 @@ namespace FreeSql.Internal.CommonProvider { this.AsTable((type, old) => { + if (type == _tables[0].Table?.Type && string.IsNullOrEmpty(sqlT1) == false) return $"({sqlT1})"; if (type == _tables[1].Table?.Type && string.IsNullOrEmpty(sqlT2) == false) return $"({sqlT2})"; if (type == _tables[2].Table?.Type && string.IsNullOrEmpty(sqlT3) == false) return $"({sqlT3})"; if (type == _tables[3].Table?.Type && string.IsNullOrEmpty(sqlT4) == false) return $"({sqlT4})"; @@ -50,7 +51,7 @@ namespace FreeSql.Internal.CommonProvider return old; }); - if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6};\r\n{sqlT7};\r\n{sqlT8};\r\n{sqlT9};\r\n{sqlT10};\r\n{sqlT11};\r\n{sqlT12};\r\n{sqlT13};", parms)); + if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT1};\r\n{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6};\r\n{sqlT7};\r\n{sqlT8};\r\n{sqlT9};\r\n{sqlT10};\r\n{sqlT11};\r\n{sqlT12};\r\n{sqlT13}", parms)); return this; } @@ -241,61 +242,61 @@ namespace FreeSql.Internal.CommonProvider TMember ISelect.Min(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Min((Expression>)expModify); + return (this as ISelect).Min((Expression>)expModify); } ISelect ISelect.OrderBy(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderBy((Expression>)expModify); + return (this as ISelect).OrderBy((Expression>)expModify); } ISelect ISelect.OrderByDescending(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByDescending((Expression>)expModify); + return (this as ISelect).OrderByDescending((Expression>)expModify); } ISelect ISelect.OrderByIf(bool condition, Expression, TMember>> column, bool descending) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); + return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); } decimal ISelect.Sum(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Sum((Expression>)expModify); + return (this as ISelect).Sum((Expression>)expModify); } List ISelect.ToList(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToList((Expression>)expModify); + return (this as ISelect).ToList((Expression>)expModify); } public void ToChunk(Expression, TReturn>> select, int size, Action>> done) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - (this as ISelect).ToChunk((Expression>)expModify, size, done); + (this as ISelect).ToChunk((Expression>)expModify, size, done); } DataTable ISelect.ToDataTable(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTable((Expression>)expModify); + return (this as ISelect).ToDataTable((Expression>)expModify); } int ISelect.InsertInto(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertInto(tableName, (Expression>)expModify); + return (this as ISelect).InsertInto(tableName, (Expression>)expModify); } string ISelect.ToSql(Expression, TReturn>> select, FieldAliasOptions fieldAlias) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); + return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); } ISelect ISelect.LeftJoin(Expression, bool>> exp) @@ -424,43 +425,43 @@ namespace FreeSql.Internal.CommonProvider Task ISelect.AvgAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).AvgAsync((Expression>)expModify); + return (this as ISelect).AvgAsync((Expression>)expModify); } Task ISelect.MaxAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MaxAsync((Expression>)expModify); + return (this as ISelect).MaxAsync((Expression>)expModify); } Task ISelect.MinAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MinAsync((Expression>)expModify); + return (this as ISelect).MinAsync((Expression>)expModify); } Task ISelect.SumAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).SumAsync((Expression>)expModify); + return (this as ISelect).SumAsync((Expression>)expModify); } Task> ISelect.ToListAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToListAsync((Expression>)expModify); + return (this as ISelect).ToListAsync((Expression>)expModify); } Task ISelect.ToDataTableAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTableAsync((Expression>)expModify); + return (this as ISelect).ToDataTableAsync((Expression>)expModify); } Task ISelect.InsertIntoAsync(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); + return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); } async Task ISelect.AnyAsync(Expression, bool>> exp) diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select14Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select14Provider.cs index 6df2c42e..2397fc47 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select14Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select14Provider.cs @@ -36,6 +36,7 @@ namespace FreeSql.Internal.CommonProvider { this.AsTable((type, old) => { + if (type == _tables[0].Table?.Type && string.IsNullOrEmpty(sqlT1) == false) return $"({sqlT1})"; if (type == _tables[1].Table?.Type && string.IsNullOrEmpty(sqlT2) == false) return $"({sqlT2})"; if (type == _tables[2].Table?.Type && string.IsNullOrEmpty(sqlT3) == false) return $"({sqlT3})"; if (type == _tables[3].Table?.Type && string.IsNullOrEmpty(sqlT4) == false) return $"({sqlT4})"; @@ -52,7 +53,7 @@ namespace FreeSql.Internal.CommonProvider return old; }); - if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6};\r\n{sqlT7};\r\n{sqlT8};\r\n{sqlT9};\r\n{sqlT10};\r\n{sqlT11};\r\n{sqlT12};\r\n{sqlT13};\r\n{sqlT14};", parms)); + if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT1};\r\n{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6};\r\n{sqlT7};\r\n{sqlT8};\r\n{sqlT9};\r\n{sqlT10};\r\n{sqlT11};\r\n{sqlT12};\r\n{sqlT13};\r\n{sqlT14}", parms)); return this; } @@ -243,61 +244,61 @@ namespace FreeSql.Internal.CommonProvider TMember ISelect.Min(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Min((Expression>)expModify); + return (this as ISelect).Min((Expression>)expModify); } ISelect ISelect.OrderBy(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderBy((Expression>)expModify); + return (this as ISelect).OrderBy((Expression>)expModify); } ISelect ISelect.OrderByDescending(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByDescending((Expression>)expModify); + return (this as ISelect).OrderByDescending((Expression>)expModify); } ISelect ISelect.OrderByIf(bool condition, Expression, TMember>> column, bool descending) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); + return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); } decimal ISelect.Sum(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Sum((Expression>)expModify); + return (this as ISelect).Sum((Expression>)expModify); } List ISelect.ToList(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToList((Expression>)expModify); + return (this as ISelect).ToList((Expression>)expModify); } public void ToChunk(Expression, TReturn>> select, int size, Action>> done) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - (this as ISelect).ToChunk((Expression>)expModify, size, done); + (this as ISelect).ToChunk((Expression>)expModify, size, done); } DataTable ISelect.ToDataTable(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTable((Expression>)expModify); + return (this as ISelect).ToDataTable((Expression>)expModify); } int ISelect.InsertInto(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertInto(tableName, (Expression>)expModify); + return (this as ISelect).InsertInto(tableName, (Expression>)expModify); } string ISelect.ToSql(Expression, TReturn>> select, FieldAliasOptions fieldAlias) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); + return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); } ISelect ISelect.LeftJoin(Expression, bool>> exp) @@ -426,43 +427,43 @@ namespace FreeSql.Internal.CommonProvider Task ISelect.AvgAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).AvgAsync((Expression>)expModify); + return (this as ISelect).AvgAsync((Expression>)expModify); } Task ISelect.MaxAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MaxAsync((Expression>)expModify); + return (this as ISelect).MaxAsync((Expression>)expModify); } Task ISelect.MinAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MinAsync((Expression>)expModify); + return (this as ISelect).MinAsync((Expression>)expModify); } Task ISelect.SumAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).SumAsync((Expression>)expModify); + return (this as ISelect).SumAsync((Expression>)expModify); } Task> ISelect.ToListAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToListAsync((Expression>)expModify); + return (this as ISelect).ToListAsync((Expression>)expModify); } Task ISelect.ToDataTableAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTableAsync((Expression>)expModify); + return (this as ISelect).ToDataTableAsync((Expression>)expModify); } Task ISelect.InsertIntoAsync(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); + return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); } async Task ISelect.AnyAsync(Expression, bool>> exp) diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select15Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select15Provider.cs index f4bb94fe..c6c878ef 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select15Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select15Provider.cs @@ -37,6 +37,7 @@ namespace FreeSql.Internal.CommonProvider { this.AsTable((type, old) => { + if (type == _tables[0].Table?.Type && string.IsNullOrEmpty(sqlT1) == false) return $"({sqlT1})"; if (type == _tables[1].Table?.Type && string.IsNullOrEmpty(sqlT2) == false) return $"({sqlT2})"; if (type == _tables[2].Table?.Type && string.IsNullOrEmpty(sqlT3) == false) return $"({sqlT3})"; if (type == _tables[3].Table?.Type && string.IsNullOrEmpty(sqlT4) == false) return $"({sqlT4})"; @@ -54,7 +55,7 @@ namespace FreeSql.Internal.CommonProvider return old; }); - if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6};\r\n{sqlT7};\r\n{sqlT8};\r\n{sqlT9};\r\n{sqlT10};\r\n{sqlT11};\r\n{sqlT12};\r\n{sqlT13};\r\n{sqlT14};\r\n{sqlT15};", parms)); + if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT1};\r\n{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6};\r\n{sqlT7};\r\n{sqlT8};\r\n{sqlT9};\r\n{sqlT10};\r\n{sqlT11};\r\n{sqlT12};\r\n{sqlT13};\r\n{sqlT14};\r\n{sqlT15}", parms)); return this; } @@ -245,61 +246,61 @@ namespace FreeSql.Internal.CommonProvider TMember ISelect.Min(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Min((Expression>)expModify); + return (this as ISelect).Min((Expression>)expModify); } ISelect ISelect.OrderBy(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderBy((Expression>)expModify); + return (this as ISelect).OrderBy((Expression>)expModify); } ISelect ISelect.OrderByDescending(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByDescending((Expression>)expModify); + return (this as ISelect).OrderByDescending((Expression>)expModify); } ISelect ISelect.OrderByIf(bool condition, Expression, TMember>> column, bool descending) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); + return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); } decimal ISelect.Sum(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Sum((Expression>)expModify); + return (this as ISelect).Sum((Expression>)expModify); } List ISelect.ToList(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToList((Expression>)expModify); + return (this as ISelect).ToList((Expression>)expModify); } public void ToChunk(Expression, TReturn>> select, int size, Action>> done) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - (this as ISelect).ToChunk((Expression>)expModify, size, done); + (this as ISelect).ToChunk((Expression>)expModify, size, done); } DataTable ISelect.ToDataTable(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTable((Expression>)expModify); + return (this as ISelect).ToDataTable((Expression>)expModify); } int ISelect.InsertInto(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertInto(tableName, (Expression>)expModify); + return (this as ISelect).InsertInto(tableName, (Expression>)expModify); } string ISelect.ToSql(Expression, TReturn>> select, FieldAliasOptions fieldAlias) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); + return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); } ISelect ISelect.LeftJoin(Expression, bool>> exp) @@ -428,43 +429,43 @@ namespace FreeSql.Internal.CommonProvider Task ISelect.AvgAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).AvgAsync((Expression>)expModify); + return (this as ISelect).AvgAsync((Expression>)expModify); } Task ISelect.MaxAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MaxAsync((Expression>)expModify); + return (this as ISelect).MaxAsync((Expression>)expModify); } Task ISelect.MinAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MinAsync((Expression>)expModify); + return (this as ISelect).MinAsync((Expression>)expModify); } Task ISelect.SumAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).SumAsync((Expression>)expModify); + return (this as ISelect).SumAsync((Expression>)expModify); } Task> ISelect.ToListAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToListAsync((Expression>)expModify); + return (this as ISelect).ToListAsync((Expression>)expModify); } Task ISelect.ToDataTableAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTableAsync((Expression>)expModify); + return (this as ISelect).ToDataTableAsync((Expression>)expModify); } Task ISelect.InsertIntoAsync(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); + return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); } async Task ISelect.AnyAsync(Expression, bool>> exp) diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select16Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select16Provider.cs index 438470e7..e2fcaa72 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select16Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select16Provider.cs @@ -38,6 +38,7 @@ namespace FreeSql.Internal.CommonProvider { this.AsTable((type, old) => { + if (type == _tables[0].Table?.Type && string.IsNullOrEmpty(sqlT1) == false) return $"({sqlT1})"; if (type == _tables[1].Table?.Type && string.IsNullOrEmpty(sqlT2) == false) return $"({sqlT2})"; if (type == _tables[2].Table?.Type && string.IsNullOrEmpty(sqlT3) == false) return $"({sqlT3})"; if (type == _tables[3].Table?.Type && string.IsNullOrEmpty(sqlT4) == false) return $"({sqlT4})"; @@ -56,7 +57,7 @@ namespace FreeSql.Internal.CommonProvider return old; }); - if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6};\r\n{sqlT7};\r\n{sqlT8};\r\n{sqlT9};\r\n{sqlT10};\r\n{sqlT11};\r\n{sqlT12};\r\n{sqlT13};\r\n{sqlT14};\r\n{sqlT15};\r\n{sqlT16};", parms)); + if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT1};\r\n{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6};\r\n{sqlT7};\r\n{sqlT8};\r\n{sqlT9};\r\n{sqlT10};\r\n{sqlT11};\r\n{sqlT12};\r\n{sqlT13};\r\n{sqlT14};\r\n{sqlT15};\r\n{sqlT16}", parms)); return this; } @@ -247,61 +248,61 @@ namespace FreeSql.Internal.CommonProvider TMember ISelect.Min(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Min((Expression>)expModify); + return (this as ISelect).Min((Expression>)expModify); } ISelect ISelect.OrderBy(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderBy((Expression>)expModify); + return (this as ISelect).OrderBy((Expression>)expModify); } ISelect ISelect.OrderByDescending(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByDescending((Expression>)expModify); + return (this as ISelect).OrderByDescending((Expression>)expModify); } ISelect ISelect.OrderByIf(bool condition, Expression, TMember>> column, bool descending) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); + return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); } decimal ISelect.Sum(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Sum((Expression>)expModify); + return (this as ISelect).Sum((Expression>)expModify); } List ISelect.ToList(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToList((Expression>)expModify); + return (this as ISelect).ToList((Expression>)expModify); } public void ToChunk(Expression, TReturn>> select, int size, Action>> done) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - (this as ISelect).ToChunk((Expression>)expModify, size, done); + (this as ISelect).ToChunk((Expression>)expModify, size, done); } DataTable ISelect.ToDataTable(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTable((Expression>)expModify); + return (this as ISelect).ToDataTable((Expression>)expModify); } int ISelect.InsertInto(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertInto(tableName, (Expression>)expModify); + return (this as ISelect).InsertInto(tableName, (Expression>)expModify); } string ISelect.ToSql(Expression, TReturn>> select, FieldAliasOptions fieldAlias) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); + return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); } ISelect ISelect.LeftJoin(Expression, bool>> exp) @@ -430,43 +431,43 @@ namespace FreeSql.Internal.CommonProvider Task ISelect.AvgAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).AvgAsync((Expression>)expModify); + return (this as ISelect).AvgAsync((Expression>)expModify); } Task ISelect.MaxAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MaxAsync((Expression>)expModify); + return (this as ISelect).MaxAsync((Expression>)expModify); } Task ISelect.MinAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MinAsync((Expression>)expModify); + return (this as ISelect).MinAsync((Expression>)expModify); } Task ISelect.SumAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).SumAsync((Expression>)expModify); + return (this as ISelect).SumAsync((Expression>)expModify); } Task> ISelect.ToListAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToListAsync((Expression>)expModify); + return (this as ISelect).ToListAsync((Expression>)expModify); } Task ISelect.ToDataTableAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTableAsync((Expression>)expModify); + return (this as ISelect).ToDataTableAsync((Expression>)expModify); } Task ISelect.InsertIntoAsync(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); + return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); } async Task ISelect.AnyAsync(Expression, bool>> exp) diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select2Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select2Provider.cs index 6441c35e..1e550e25 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select2Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select2Provider.cs @@ -8,9 +8,6 @@ using System.Threading.Tasks; namespace FreeSql.Internal.CommonProvider { - - - public abstract class Select2Provider : Select0Provider, T1>, ISelect where T2 : class { @@ -26,11 +23,12 @@ namespace FreeSql.Internal.CommonProvider { this.AsTable((type, old) => { + if (type == _tables[0].Table?.Type && string.IsNullOrEmpty(sqlT1) == false) return $"({sqlT1})"; if (type == _tables[1].Table?.Type && string.IsNullOrEmpty(sqlT2) == false) return $"({sqlT2})"; return old; }); - if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT2};", parms)); + if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT1};\r\n{sqlT2}", parms)); return this; } @@ -221,61 +219,61 @@ namespace FreeSql.Internal.CommonProvider TMember ISelect.Min(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Min((Expression>)expModify); + return (this as ISelect).Min((Expression>)expModify); } ISelect ISelect.OrderBy(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderBy((Expression>)expModify); + return (this as ISelect).OrderBy((Expression>)expModify); } ISelect ISelect.OrderByDescending(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByDescending((Expression>)expModify); + return (this as ISelect).OrderByDescending((Expression>)expModify); } ISelect ISelect.OrderByIf(bool condition, Expression, TMember>> column, bool descending) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); + return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); } decimal ISelect.Sum(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Sum((Expression>)expModify); + return (this as ISelect).Sum((Expression>)expModify); } List ISelect.ToList(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToList((Expression>)expModify); + return (this as ISelect).ToList((Expression>)expModify); } public void ToChunk(Expression, TReturn>> select, int size, Action>> done) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - (this as ISelect).ToChunk((Expression>)expModify, size, done); + (this as ISelect).ToChunk((Expression>)expModify, size, done); } DataTable ISelect.ToDataTable(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTable((Expression>)expModify); + return (this as ISelect).ToDataTable((Expression>)expModify); } int ISelect.InsertInto(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertInto(tableName, (Expression>)expModify); + return (this as ISelect).InsertInto(tableName, (Expression>)expModify); } string ISelect.ToSql(Expression, TReturn>> select, FieldAliasOptions fieldAlias) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); + return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); } ISelect ISelect.LeftJoin(Expression, bool>> exp) @@ -404,43 +402,43 @@ namespace FreeSql.Internal.CommonProvider Task ISelect.AvgAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).AvgAsync((Expression>)expModify); + return (this as ISelect).AvgAsync((Expression>)expModify); } Task ISelect.MaxAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MaxAsync((Expression>)expModify); + return (this as ISelect).MaxAsync((Expression>)expModify); } Task ISelect.MinAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MinAsync((Expression>)expModify); + return (this as ISelect).MinAsync((Expression>)expModify); } Task ISelect.SumAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).SumAsync((Expression>)expModify); + return (this as ISelect).SumAsync((Expression>)expModify); } Task> ISelect.ToListAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToListAsync((Expression>)expModify); + return (this as ISelect).ToListAsync((Expression>)expModify); } Task ISelect.ToDataTableAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTableAsync((Expression>)expModify); + return (this as ISelect).ToDataTableAsync((Expression>)expModify); } Task ISelect.InsertIntoAsync(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); + return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); } async Task ISelect.AnyAsync(Expression, bool>> exp) @@ -461,8 +459,4 @@ namespace FreeSql.Internal.CommonProvider } - - - - } \ No newline at end of file diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select3Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select3Provider.cs index b6ee8e7b..8d7f5b40 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select3Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select3Provider.cs @@ -8,9 +8,6 @@ using System.Threading.Tasks; namespace FreeSql.Internal.CommonProvider { - - - public abstract class Select3Provider : Select0Provider, T1>, ISelect where T2 : class where T3 : class { @@ -27,12 +24,13 @@ namespace FreeSql.Internal.CommonProvider { this.AsTable((type, old) => { + if (type == _tables[0].Table?.Type && string.IsNullOrEmpty(sqlT1) == false) return $"({sqlT1})"; if (type == _tables[1].Table?.Type && string.IsNullOrEmpty(sqlT2) == false) return $"({sqlT2})"; if (type == _tables[2].Table?.Type && string.IsNullOrEmpty(sqlT3) == false) return $"({sqlT3})"; return old; }); - if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT2};\r\n{sqlT3};", parms)); + if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT1};\r\n{sqlT2};\r\n{sqlT3}", parms)); return this; } @@ -223,61 +221,61 @@ namespace FreeSql.Internal.CommonProvider TMember ISelect.Min(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Min((Expression>)expModify); + return (this as ISelect).Min((Expression>)expModify); } ISelect ISelect.OrderBy(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderBy((Expression>)expModify); + return (this as ISelect).OrderBy((Expression>)expModify); } ISelect ISelect.OrderByDescending(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByDescending((Expression>)expModify); + return (this as ISelect).OrderByDescending((Expression>)expModify); } ISelect ISelect.OrderByIf(bool condition, Expression, TMember>> column, bool descending) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); + return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); } decimal ISelect.Sum(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Sum((Expression>)expModify); + return (this as ISelect).Sum((Expression>)expModify); } List ISelect.ToList(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToList((Expression>)expModify); + return (this as ISelect).ToList((Expression>)expModify); } public void ToChunk(Expression, TReturn>> select, int size, Action>> done) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - (this as ISelect).ToChunk((Expression>)expModify, size, done); + (this as ISelect).ToChunk((Expression>)expModify, size, done); } DataTable ISelect.ToDataTable(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTable((Expression>)expModify); + return (this as ISelect).ToDataTable((Expression>)expModify); } int ISelect.InsertInto(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertInto(tableName, (Expression>)expModify); + return (this as ISelect).InsertInto(tableName, (Expression>)expModify); } string ISelect.ToSql(Expression, TReturn>> select, FieldAliasOptions fieldAlias) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); + return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); } ISelect ISelect.LeftJoin(Expression, bool>> exp) @@ -406,43 +404,43 @@ namespace FreeSql.Internal.CommonProvider Task ISelect.AvgAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).AvgAsync((Expression>)expModify); + return (this as ISelect).AvgAsync((Expression>)expModify); } Task ISelect.MaxAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MaxAsync((Expression>)expModify); + return (this as ISelect).MaxAsync((Expression>)expModify); } Task ISelect.MinAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MinAsync((Expression>)expModify); + return (this as ISelect).MinAsync((Expression>)expModify); } Task ISelect.SumAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).SumAsync((Expression>)expModify); + return (this as ISelect).SumAsync((Expression>)expModify); } Task> ISelect.ToListAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToListAsync((Expression>)expModify); + return (this as ISelect).ToListAsync((Expression>)expModify); } Task ISelect.ToDataTableAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTableAsync((Expression>)expModify); + return (this as ISelect).ToDataTableAsync((Expression>)expModify); } Task ISelect.InsertIntoAsync(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); + return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); } async Task ISelect.AnyAsync(Expression, bool>> exp) diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select4Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select4Provider.cs index 044622e0..5890fa7f 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select4Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select4Provider.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; namespace FreeSql.Internal.CommonProvider { - public abstract class Select4Provider : Select0Provider, T1>, ISelect where T2 : class where T3 : class where T4 : class { @@ -27,13 +26,14 @@ namespace FreeSql.Internal.CommonProvider { this.AsTable((type, old) => { + if (type == _tables[0].Table?.Type && string.IsNullOrEmpty(sqlT1) == false) return $"({sqlT1})"; if (type == _tables[1].Table?.Type && string.IsNullOrEmpty(sqlT2) == false) return $"({sqlT2})"; if (type == _tables[2].Table?.Type && string.IsNullOrEmpty(sqlT3) == false) return $"({sqlT3})"; if (type == _tables[3].Table?.Type && string.IsNullOrEmpty(sqlT4) == false) return $"({sqlT4})"; return old; }); - if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT2};\r\n{sqlT3};\r\n{sqlT4};", parms)); + if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT1};\r\n{sqlT2};\r\n{sqlT3};\r\n{sqlT4}", parms)); return this; } @@ -224,61 +224,61 @@ namespace FreeSql.Internal.CommonProvider TMember ISelect.Min(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Min((Expression>)expModify); + return (this as ISelect).Min((Expression>)expModify); } ISelect ISelect.OrderBy(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderBy((Expression>)expModify); + return (this as ISelect).OrderBy((Expression>)expModify); } ISelect ISelect.OrderByDescending(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByDescending((Expression>)expModify); + return (this as ISelect).OrderByDescending((Expression>)expModify); } ISelect ISelect.OrderByIf(bool condition, Expression, TMember>> column, bool descending) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); + return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); } decimal ISelect.Sum(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Sum((Expression>)expModify); + return (this as ISelect).Sum((Expression>)expModify); } List ISelect.ToList(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToList((Expression>)expModify); + return (this as ISelect).ToList((Expression>)expModify); } public void ToChunk(Expression, TReturn>> select, int size, Action>> done) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - (this as ISelect).ToChunk((Expression>)expModify, size, done); + (this as ISelect).ToChunk((Expression>)expModify, size, done); } DataTable ISelect.ToDataTable(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTable((Expression>)expModify); + return (this as ISelect).ToDataTable((Expression>)expModify); } int ISelect.InsertInto(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertInto(tableName, (Expression>)expModify); + return (this as ISelect).InsertInto(tableName, (Expression>)expModify); } string ISelect.ToSql(Expression, TReturn>> select, FieldAliasOptions fieldAlias) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); + return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); } ISelect ISelect.LeftJoin(Expression, bool>> exp) @@ -407,43 +407,43 @@ namespace FreeSql.Internal.CommonProvider Task ISelect.AvgAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).AvgAsync((Expression>)expModify); + return (this as ISelect).AvgAsync((Expression>)expModify); } Task ISelect.MaxAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MaxAsync((Expression>)expModify); + return (this as ISelect).MaxAsync((Expression>)expModify); } Task ISelect.MinAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MinAsync((Expression>)expModify); + return (this as ISelect).MinAsync((Expression>)expModify); } Task ISelect.SumAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).SumAsync((Expression>)expModify); + return (this as ISelect).SumAsync((Expression>)expModify); } Task> ISelect.ToListAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToListAsync((Expression>)expModify); + return (this as ISelect).ToListAsync((Expression>)expModify); } Task ISelect.ToDataTableAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTableAsync((Expression>)expModify); + return (this as ISelect).ToDataTableAsync((Expression>)expModify); } Task ISelect.InsertIntoAsync(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); + return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); } async Task ISelect.AnyAsync(Expression, bool>> exp) @@ -464,4 +464,5 @@ namespace FreeSql.Internal.CommonProvider } + } \ No newline at end of file diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select5Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select5Provider.cs index 1a15b9c1..7ce48dac 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select5Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select5Provider.cs @@ -8,7 +8,6 @@ using System.Threading.Tasks; namespace FreeSql.Internal.CommonProvider { - public abstract class Select5Provider : Select0Provider, T1>, ISelect where T2 : class where T3 : class where T4 : class where T5 : class { @@ -27,6 +26,7 @@ namespace FreeSql.Internal.CommonProvider { this.AsTable((type, old) => { + if (type == _tables[0].Table?.Type && string.IsNullOrEmpty(sqlT1) == false) return $"({sqlT1})"; if (type == _tables[1].Table?.Type && string.IsNullOrEmpty(sqlT2) == false) return $"({sqlT2})"; if (type == _tables[2].Table?.Type && string.IsNullOrEmpty(sqlT3) == false) return $"({sqlT3})"; if (type == _tables[3].Table?.Type && string.IsNullOrEmpty(sqlT4) == false) return $"({sqlT4})"; @@ -34,7 +34,7 @@ namespace FreeSql.Internal.CommonProvider return old; }); - if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};", parms)); + if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT1};\r\n{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5}", parms)); return this; } @@ -225,61 +225,61 @@ namespace FreeSql.Internal.CommonProvider TMember ISelect.Min(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Min((Expression>)expModify); + return (this as ISelect).Min((Expression>)expModify); } ISelect ISelect.OrderBy(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderBy((Expression>)expModify); + return (this as ISelect).OrderBy((Expression>)expModify); } ISelect ISelect.OrderByDescending(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByDescending((Expression>)expModify); + return (this as ISelect).OrderByDescending((Expression>)expModify); } ISelect ISelect.OrderByIf(bool condition, Expression, TMember>> column, bool descending) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); + return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); } decimal ISelect.Sum(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Sum((Expression>)expModify); + return (this as ISelect).Sum((Expression>)expModify); } List ISelect.ToList(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToList((Expression>)expModify); + return (this as ISelect).ToList((Expression>)expModify); } public void ToChunk(Expression, TReturn>> select, int size, Action>> done) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - (this as ISelect).ToChunk((Expression>)expModify, size, done); + (this as ISelect).ToChunk((Expression>)expModify, size, done); } DataTable ISelect.ToDataTable(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTable((Expression>)expModify); + return (this as ISelect).ToDataTable((Expression>)expModify); } int ISelect.InsertInto(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertInto(tableName, (Expression>)expModify); + return (this as ISelect).InsertInto(tableName, (Expression>)expModify); } string ISelect.ToSql(Expression, TReturn>> select, FieldAliasOptions fieldAlias) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); + return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); } ISelect ISelect.LeftJoin(Expression, bool>> exp) @@ -408,43 +408,43 @@ namespace FreeSql.Internal.CommonProvider Task ISelect.AvgAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).AvgAsync((Expression>)expModify); + return (this as ISelect).AvgAsync((Expression>)expModify); } Task ISelect.MaxAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MaxAsync((Expression>)expModify); + return (this as ISelect).MaxAsync((Expression>)expModify); } Task ISelect.MinAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MinAsync((Expression>)expModify); + return (this as ISelect).MinAsync((Expression>)expModify); } Task ISelect.SumAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).SumAsync((Expression>)expModify); + return (this as ISelect).SumAsync((Expression>)expModify); } Task> ISelect.ToListAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToListAsync((Expression>)expModify); + return (this as ISelect).ToListAsync((Expression>)expModify); } Task ISelect.ToDataTableAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTableAsync((Expression>)expModify); + return (this as ISelect).ToDataTableAsync((Expression>)expModify); } Task ISelect.InsertIntoAsync(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); + return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); } async Task ISelect.AnyAsync(Expression, bool>> exp) @@ -465,5 +465,4 @@ namespace FreeSql.Internal.CommonProvider } - } \ No newline at end of file diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select6Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select6Provider.cs index fc16cb9c..7c39a101 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select6Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select6Provider.cs @@ -8,7 +8,6 @@ using System.Threading.Tasks; namespace FreeSql.Internal.CommonProvider { - public abstract class Select6Provider : Select0Provider, T1>, ISelect where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class { @@ -28,6 +27,7 @@ namespace FreeSql.Internal.CommonProvider { this.AsTable((type, old) => { + if (type == _tables[0].Table?.Type && string.IsNullOrEmpty(sqlT1) == false) return $"({sqlT1})"; if (type == _tables[1].Table?.Type && string.IsNullOrEmpty(sqlT2) == false) return $"({sqlT2})"; if (type == _tables[2].Table?.Type && string.IsNullOrEmpty(sqlT3) == false) return $"({sqlT3})"; if (type == _tables[3].Table?.Type && string.IsNullOrEmpty(sqlT4) == false) return $"({sqlT4})"; @@ -36,7 +36,7 @@ namespace FreeSql.Internal.CommonProvider return old; }); - if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6};", parms)); + if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT1};\r\n{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6}", parms)); return this; } @@ -227,61 +227,61 @@ namespace FreeSql.Internal.CommonProvider TMember ISelect.Min(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Min((Expression>)expModify); + return (this as ISelect).Min((Expression>)expModify); } ISelect ISelect.OrderBy(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderBy((Expression>)expModify); + return (this as ISelect).OrderBy((Expression>)expModify); } ISelect ISelect.OrderByDescending(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByDescending((Expression>)expModify); + return (this as ISelect).OrderByDescending((Expression>)expModify); } ISelect ISelect.OrderByIf(bool condition, Expression, TMember>> column, bool descending) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); + return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); } decimal ISelect.Sum(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Sum((Expression>)expModify); + return (this as ISelect).Sum((Expression>)expModify); } List ISelect.ToList(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToList((Expression>)expModify); + return (this as ISelect).ToList((Expression>)expModify); } public void ToChunk(Expression, TReturn>> select, int size, Action>> done) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - (this as ISelect).ToChunk((Expression>)expModify, size, done); + (this as ISelect).ToChunk((Expression>)expModify, size, done); } DataTable ISelect.ToDataTable(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTable((Expression>)expModify); + return (this as ISelect).ToDataTable((Expression>)expModify); } int ISelect.InsertInto(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertInto(tableName, (Expression>)expModify); + return (this as ISelect).InsertInto(tableName, (Expression>)expModify); } string ISelect.ToSql(Expression, TReturn>> select, FieldAliasOptions fieldAlias) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); + return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); } ISelect ISelect.LeftJoin(Expression, bool>> exp) @@ -410,43 +410,43 @@ namespace FreeSql.Internal.CommonProvider Task ISelect.AvgAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).AvgAsync((Expression>)expModify); + return (this as ISelect).AvgAsync((Expression>)expModify); } Task ISelect.MaxAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MaxAsync((Expression>)expModify); + return (this as ISelect).MaxAsync((Expression>)expModify); } Task ISelect.MinAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MinAsync((Expression>)expModify); + return (this as ISelect).MinAsync((Expression>)expModify); } Task ISelect.SumAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).SumAsync((Expression>)expModify); + return (this as ISelect).SumAsync((Expression>)expModify); } Task> ISelect.ToListAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToListAsync((Expression>)expModify); + return (this as ISelect).ToListAsync((Expression>)expModify); } Task ISelect.ToDataTableAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTableAsync((Expression>)expModify); + return (this as ISelect).ToDataTableAsync((Expression>)expModify); } Task ISelect.InsertIntoAsync(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); + return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); } async Task ISelect.AnyAsync(Expression, bool>> exp) diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select7Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select7Provider.cs index 9a134de8..117039f2 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select7Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select7Provider.cs @@ -9,6 +9,8 @@ using System.Threading.Tasks; namespace FreeSql.Internal.CommonProvider { + + public abstract class Select7Provider : Select0Provider, T1>, ISelect where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class { @@ -29,6 +31,7 @@ namespace FreeSql.Internal.CommonProvider { this.AsTable((type, old) => { + if (type == _tables[0].Table?.Type && string.IsNullOrEmpty(sqlT1) == false) return $"({sqlT1})"; if (type == _tables[1].Table?.Type && string.IsNullOrEmpty(sqlT2) == false) return $"({sqlT2})"; if (type == _tables[2].Table?.Type && string.IsNullOrEmpty(sqlT3) == false) return $"({sqlT3})"; if (type == _tables[3].Table?.Type && string.IsNullOrEmpty(sqlT4) == false) return $"({sqlT4})"; @@ -38,7 +41,7 @@ namespace FreeSql.Internal.CommonProvider return old; }); - if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6};\r\n{sqlT7};", parms)); + if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT1};\r\n{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6};\r\n{sqlT7}", parms)); return this; } @@ -229,61 +232,61 @@ namespace FreeSql.Internal.CommonProvider TMember ISelect.Min(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Min((Expression>)expModify); + return (this as ISelect).Min((Expression>)expModify); } ISelect ISelect.OrderBy(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderBy((Expression>)expModify); + return (this as ISelect).OrderBy((Expression>)expModify); } ISelect ISelect.OrderByDescending(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByDescending((Expression>)expModify); + return (this as ISelect).OrderByDescending((Expression>)expModify); } ISelect ISelect.OrderByIf(bool condition, Expression, TMember>> column, bool descending) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); + return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); } decimal ISelect.Sum(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Sum((Expression>)expModify); + return (this as ISelect).Sum((Expression>)expModify); } List ISelect.ToList(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToList((Expression>)expModify); + return (this as ISelect).ToList((Expression>)expModify); } public void ToChunk(Expression, TReturn>> select, int size, Action>> done) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - (this as ISelect).ToChunk((Expression>)expModify, size, done); + (this as ISelect).ToChunk((Expression>)expModify, size, done); } DataTable ISelect.ToDataTable(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTable((Expression>)expModify); + return (this as ISelect).ToDataTable((Expression>)expModify); } int ISelect.InsertInto(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertInto(tableName, (Expression>)expModify); + return (this as ISelect).InsertInto(tableName, (Expression>)expModify); } string ISelect.ToSql(Expression, TReturn>> select, FieldAliasOptions fieldAlias) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); + return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); } ISelect ISelect.LeftJoin(Expression, bool>> exp) @@ -412,43 +415,43 @@ namespace FreeSql.Internal.CommonProvider Task ISelect.AvgAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).AvgAsync((Expression>)expModify); + return (this as ISelect).AvgAsync((Expression>)expModify); } Task ISelect.MaxAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MaxAsync((Expression>)expModify); + return (this as ISelect).MaxAsync((Expression>)expModify); } Task ISelect.MinAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MinAsync((Expression>)expModify); + return (this as ISelect).MinAsync((Expression>)expModify); } Task ISelect.SumAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).SumAsync((Expression>)expModify); + return (this as ISelect).SumAsync((Expression>)expModify); } Task> ISelect.ToListAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToListAsync((Expression>)expModify); + return (this as ISelect).ToListAsync((Expression>)expModify); } Task ISelect.ToDataTableAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTableAsync((Expression>)expModify); + return (this as ISelect).ToDataTableAsync((Expression>)expModify); } Task ISelect.InsertIntoAsync(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); + return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); } async Task ISelect.AnyAsync(Expression, bool>> exp) diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select8Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select8Provider.cs index 98b3b85a..10f6a5a6 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select8Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select8Provider.cs @@ -8,8 +8,6 @@ using System.Threading.Tasks; namespace FreeSql.Internal.CommonProvider { - - public abstract class Select8Provider : Select0Provider, T1>, ISelect where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class { @@ -31,6 +29,7 @@ namespace FreeSql.Internal.CommonProvider { this.AsTable((type, old) => { + if (type == _tables[0].Table?.Type && string.IsNullOrEmpty(sqlT1) == false) return $"({sqlT1})"; if (type == _tables[1].Table?.Type && string.IsNullOrEmpty(sqlT2) == false) return $"({sqlT2})"; if (type == _tables[2].Table?.Type && string.IsNullOrEmpty(sqlT3) == false) return $"({sqlT3})"; if (type == _tables[3].Table?.Type && string.IsNullOrEmpty(sqlT4) == false) return $"({sqlT4})"; @@ -41,7 +40,7 @@ namespace FreeSql.Internal.CommonProvider return old; }); - if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6};\r\n{sqlT7};\r\n{sqlT8};", parms)); + if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT1};\r\n{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6};\r\n{sqlT7};\r\n{sqlT8}", parms)); return this; } @@ -232,61 +231,61 @@ namespace FreeSql.Internal.CommonProvider TMember ISelect.Min(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Min((Expression>)expModify); + return (this as ISelect).Min((Expression>)expModify); } ISelect ISelect.OrderBy(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderBy((Expression>)expModify); + return (this as ISelect).OrderBy((Expression>)expModify); } ISelect ISelect.OrderByDescending(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByDescending((Expression>)expModify); + return (this as ISelect).OrderByDescending((Expression>)expModify); } ISelect ISelect.OrderByIf(bool condition, Expression, TMember>> column, bool descending) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); + return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); } decimal ISelect.Sum(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Sum((Expression>)expModify); + return (this as ISelect).Sum((Expression>)expModify); } List ISelect.ToList(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToList((Expression>)expModify); + return (this as ISelect).ToList((Expression>)expModify); } public void ToChunk(Expression, TReturn>> select, int size, Action>> done) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - (this as ISelect).ToChunk((Expression>)expModify, size, done); + (this as ISelect).ToChunk((Expression>)expModify, size, done); } DataTable ISelect.ToDataTable(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTable((Expression>)expModify); + return (this as ISelect).ToDataTable((Expression>)expModify); } int ISelect.InsertInto(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertInto(tableName, (Expression>)expModify); + return (this as ISelect).InsertInto(tableName, (Expression>)expModify); } string ISelect.ToSql(Expression, TReturn>> select, FieldAliasOptions fieldAlias) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); + return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); } ISelect ISelect.LeftJoin(Expression, bool>> exp) @@ -415,43 +414,43 @@ namespace FreeSql.Internal.CommonProvider Task ISelect.AvgAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).AvgAsync((Expression>)expModify); + return (this as ISelect).AvgAsync((Expression>)expModify); } Task ISelect.MaxAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MaxAsync((Expression>)expModify); + return (this as ISelect).MaxAsync((Expression>)expModify); } Task ISelect.MinAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MinAsync((Expression>)expModify); + return (this as ISelect).MinAsync((Expression>)expModify); } Task ISelect.SumAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).SumAsync((Expression>)expModify); + return (this as ISelect).SumAsync((Expression>)expModify); } Task> ISelect.ToListAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToListAsync((Expression>)expModify); + return (this as ISelect).ToListAsync((Expression>)expModify); } Task ISelect.ToDataTableAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTableAsync((Expression>)expModify); + return (this as ISelect).ToDataTableAsync((Expression>)expModify); } Task ISelect.InsertIntoAsync(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); + return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); } async Task ISelect.AnyAsync(Expression, bool>> exp) diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select9Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select9Provider.cs index da95085d..186d3d17 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select9Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select9Provider.cs @@ -31,6 +31,7 @@ namespace FreeSql.Internal.CommonProvider { this.AsTable((type, old) => { + if (type == _tables[0].Table?.Type && string.IsNullOrEmpty(sqlT1) == false) return $"({sqlT1})"; if (type == _tables[1].Table?.Type && string.IsNullOrEmpty(sqlT2) == false) return $"({sqlT2})"; if (type == _tables[2].Table?.Type && string.IsNullOrEmpty(sqlT3) == false) return $"({sqlT3})"; if (type == _tables[3].Table?.Type && string.IsNullOrEmpty(sqlT4) == false) return $"({sqlT4})"; @@ -42,7 +43,7 @@ namespace FreeSql.Internal.CommonProvider return old; }); - if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6};\r\n{sqlT7};\r\n{sqlT8};\r\n{sqlT9};", parms)); + if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"{sqlT1};\r\n{sqlT2};\r\n{sqlT3};\r\n{sqlT4};\r\n{sqlT5};\r\n{sqlT6};\r\n{sqlT7};\r\n{sqlT8};\r\n{sqlT9}", parms)); return this; } @@ -233,61 +234,61 @@ namespace FreeSql.Internal.CommonProvider TMember ISelect.Min(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Min((Expression>)expModify); + return (this as ISelect).Min((Expression>)expModify); } ISelect ISelect.OrderBy(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderBy((Expression>)expModify); + return (this as ISelect).OrderBy((Expression>)expModify); } ISelect ISelect.OrderByDescending(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByDescending((Expression>)expModify); + return (this as ISelect).OrderByDescending((Expression>)expModify); } ISelect ISelect.OrderByIf(bool condition, Expression, TMember>> column, bool descending) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); + return (this as ISelect).OrderByIf(condition, (Expression>)expModify, descending); } decimal ISelect.Sum(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).Sum((Expression>)expModify); + return (this as ISelect).Sum((Expression>)expModify); } List ISelect.ToList(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToList((Expression>)expModify); + return (this as ISelect).ToList((Expression>)expModify); } public void ToChunk(Expression, TReturn>> select, int size, Action>> done) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - (this as ISelect).ToChunk((Expression>)expModify, size, done); + (this as ISelect).ToChunk((Expression>)expModify, size, done); } DataTable ISelect.ToDataTable(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTable((Expression>)expModify); + return (this as ISelect).ToDataTable((Expression>)expModify); } int ISelect.InsertInto(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertInto(tableName, (Expression>)expModify); + return (this as ISelect).InsertInto(tableName, (Expression>)expModify); } string ISelect.ToSql(Expression, TReturn>> select, FieldAliasOptions fieldAlias) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); + return (this as ISelect).ToSql((Expression>)expModify, fieldAlias); } ISelect ISelect.LeftJoin(Expression, bool>> exp) @@ -416,43 +417,43 @@ namespace FreeSql.Internal.CommonProvider Task ISelect.AvgAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).AvgAsync((Expression>)expModify); + return (this as ISelect).AvgAsync((Expression>)expModify); } Task ISelect.MaxAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MaxAsync((Expression>)expModify); + return (this as ISelect).MaxAsync((Expression>)expModify); } Task ISelect.MinAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).MinAsync((Expression>)expModify); + return (this as ISelect).MinAsync((Expression>)expModify); } Task ISelect.SumAsync(Expression, TMember>> column) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); - return (this as ISelect).SumAsync((Expression>)expModify); + return (this as ISelect).SumAsync((Expression>)expModify); } Task> ISelect.ToListAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToListAsync((Expression>)expModify); + return (this as ISelect).ToListAsync((Expression>)expModify); } Task ISelect.ToDataTableAsync(Expression, TReturn>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).ToDataTableAsync((Expression>)expModify); + return (this as ISelect).ToDataTableAsync((Expression>)expModify); } Task ISelect.InsertIntoAsync(string tableName, Expression, TTargetEntity>> select) { var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); - return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); + return (this as ISelect).InsertIntoAsync(tableName, (Expression>)expModify); } async Task ISelect.AnyAsync(Expression, bool>> exp) diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/T4Temp/ISelect.tt b/FreeSql/Internal/CommonProvider/SelectProvider/T4Temp/ISelect.tt new file mode 100644 index 00000000..ad346020 --- /dev/null +++ b/FreeSql/Internal/CommonProvider/SelectProvider/T4Temp/ISelect.tt @@ -0,0 +1,161 @@ +<#@ template language="C#" #> +<#@ assembly name="System.Core" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Collections.Generic" #> + +<# + if (1 == 2) + { +#> +using FreeSql.Internal.Model; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq.Expressions; +using System.Threading.Tasks; + +namespace FreeSql +{ + + <# + var Str = ""; + var whereStr = ""; + var ISelectGroupingAggregate = new List(); + var WithSql=new List(); + for (int i = 1; i < 17; i++) + { + Str += "T" + i + ","; + var NewStr = Str.Substring(0, Str.Length - 1); +#> + + <# + if (i > 1) + { + whereStr += $"where T{i} : class "; + } #> + + <# + { + ISelectGroupingAggregate.Add($"ISelectGroupingAggregate"); + WithSql.Add($"string sqlT{i}"); + } #> + + <# + if (i == 1) continue; #> + +public interface ISelect<<#=NewStr #>> : ISelect0>, T1> <#=whereStr #> + { + +#if net40 +#else + Task AnyAsync(Expression, bool>> exp); + Task InsertIntoAsync(string tableName, Expression, TTargetEntity>> select) where TTargetEntity : class; + Task ToDataTableAsync(Expression, TReturn>> select); + Task> ToListAsync(Expression, TReturn>> select); + Task> ToListAsync(); + + Task ToOneAsync(Expression, TReturn>> select); + Task FirstAsync(Expression, TReturn>> select); + Task FirstAsync(); + + Task ToAggregateAsync(Expression, TReturn>> select); + Task SumAsync(Expression, TMember>> column); + Task MinAsync(Expression, TMember>> column); + Task MaxAsync(Expression, TMember>> column); + Task AvgAsync(Expression, TMember>> column); + + #region HzyTuple 元组 + + Task AnyAsync(Expression>, bool>> exp); + Task InsertIntoAsync(string tableName, Expression>, TTargetEntity>> select) where TTargetEntity : class; + Task ToDataTableAsync(Expression>, TReturn>> select); + Task> ToListAsync(Expression>, TReturn>> select); + + Task ToOneAsync(Expression>, TReturn>> select); + Task FirstAsync(Expression>, TReturn>> select); + + Task SumAsync(Expression>, TMember>> column); + Task MinAsync(Expression>, TMember>> column); + Task MaxAsync(Expression>, TMember>> column); + Task AvgAsync(Expression>, TMember>> column); + + #endregion + +#endif + + bool Any(Expression, bool>> exp); + int InsertInto(string tableName, Expression, TTargetEntity>> select) where TTargetEntity : class; + DataTable ToDataTable(Expression, TReturn>> select); + List ToList(Expression, TReturn>> select); + List ToList(); + void ToChunk(Expression, TReturn>> select, int size, Action>> done); + + TReturn ToOne(Expression, TReturn>> select); + TReturn First(Expression, TReturn>> select); + TDto First(); + + string ToSql(Expression, TReturn>> select, FieldAliasOptions fieldAlias = FieldAliasOptions.AsIndex); + TReturn ToAggregate(Expression, TReturn>> select); + ISelect<<#=NewStr #>> Aggregate(Expression, TReturn>> select, out TReturn result); + decimal Sum(Expression, TMember>> column); + TMember Min(Expression, TMember>> column); + TMember Max(Expression, TMember>> column); + double Avg(Expression, TMember>> column); + + ISelect<<#=NewStr #>> LeftJoin(Expression, bool>> exp); + ISelect<<#=NewStr #>> InnerJoin(Expression, bool>> exp); + ISelect<<#=NewStr #>> RightJoin(Expression, bool>> exp); + + ISelect<<#=NewStr #>> Where(Expression, bool>> exp); + ISelect<<#=NewStr #>> WhereIf(bool condition, Expression, bool>> exp); + + ISelectGrouping>> GroupBy(Expression, TKey>> exp); + + ISelect<<#=NewStr #>> OrderBy(Expression, TMember>> column); + ISelect<<#=NewStr #>> OrderByDescending(Expression, TMember>> column); + ISelect<<#=NewStr #>> OrderByIf(bool condition, Expression, TMember>> column, bool descending = false); + + ISelect<<#=NewStr #>> WithSql(<#=string.Join(",",WithSql)#>, object parms = null); + + #region HzyTuple 元组 + + bool Any(Expression>, bool>> exp); + int InsertInto(string tableName, Expression>, TTargetEntity>> select) where TTargetEntity : class; + DataTable ToDataTable(Expression>, TReturn>> select); + List ToList(Expression>, TReturn>> select); + void ToChunk(Expression>, TReturn>> select, int size, Action>> done); + + TReturn ToOne(Expression>, TReturn>> select); + TReturn First(Expression>, TReturn>> select); + + string ToSql(Expression>, TReturn>> select, FieldAliasOptions fieldAlias = FieldAliasOptions.AsIndex); + decimal Sum(Expression>, TMember>> column); + TMember Min(Expression>, TMember>> column); + TMember Max(Expression>, TMember>> column); + double Avg(Expression>, TMember>> column); + + ISelect<<#=NewStr #>> LeftJoin(Expression>, bool>> exp); + ISelect<<#=NewStr #>> InnerJoin(Expression>, bool>> exp); + ISelect<<#=NewStr #>> RightJoin(Expression>, bool>> exp); + + ISelect<<#=NewStr #>> Where(Expression>, bool>> exp); + ISelect<<#=NewStr #>> WhereIf(bool condition, Expression>, bool>> exp); + + ISelectGrouping>> GroupBy(Expression>, TKey>> exp); + + ISelect<<#=NewStr #>> OrderBy(Expression>, TMember>> column); + ISelect<<#=NewStr #>> OrderByDescending(Expression>, TMember>> column); + ISelect<<#=NewStr #>> OrderByIf(bool condition, Expression>, TMember>> column, bool descending = false); + + #endregion + + } + + <# + } #> +} + + +<# + } #> \ No newline at end of file diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/T4Temp/SelectProvider.tt b/FreeSql/Internal/CommonProvider/SelectProvider/T4Temp/SelectProvider.tt new file mode 100644 index 00000000..2c5314e9 --- /dev/null +++ b/FreeSql/Internal/CommonProvider/SelectProvider/T4Temp/SelectProvider.tt @@ -0,0 +1,524 @@ +<#@ template language="C#" #> +<#@ assembly name="System.Core" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Collections.Generic" #> + +<# + if (1 == 2) + { +#> +using FreeSql.Internal.Model; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Linq.Expressions; +using System.Threading.Tasks; + +namespace FreeSql.Internal.CommonProvider +{ + + <# + var Str = ""; + var whereStr = ""; + var ISelectGroupingAggregate = new List(); + var WithSql = new List(); + + List SyncStructure = new List(); + StringBuilder _tables = new StringBuilder(); + StringBuilder AsTable = new StringBuilder(); + var GetDbParamtersByObject = new List(); + var GetToListDtoSelector = new List(); + string[] abc = new[] + { + "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", + "w", + "x", "y", "z" + }; + for (int i = 1; i < 17; i++) + { + Str += "T" + i + ","; + var NewStr = Str.Substring(0, Str.Length - 1); +#> + + <# + if (i > 1) + { + whereStr += $"where T{i} : class "; + SyncStructure.Add($"typeof(T{i})"); + _tables.Append("_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T" + i + + ")), Alias = $\"SP10" + abc[i - 1] + "\", On = null, Type = SelectTableInfoType.From });\r\n"); + + } #> + + <# + { + ISelectGroupingAggregate.Add($"ISelectGroupingAggregate"); + WithSql.Add($"string sqlT{i}"); + GetToListDtoSelector.Add("Expression.Parameter(typeof(T" + i + "), \"" + (abc[i - 1]) + "\")"); + + AsTable.Append("if (type == _tables[" + (i - 1) + "].Table?.Type && string.IsNullOrEmpty(sqlT" + i + + ") == false) return $\"({sqlT" + i + "})\";\r\n"); + GetDbParamtersByObject.Add("{sqlT" + i + "}"); + + } #> + + <# + if (i == 1) continue; #> + + public abstract class Select<#=i #>Provider<<#=NewStr #>> : Select0Provider>, T1>, ISelect<<#=NewStr #>> + <#=whereStr #> + { + + public Select<#=i #>Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) + { + if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(<#=string.Join(",", SyncStructure) #>); + <#=_tables.ToString() #> + } + + ISelect<<#=NewStr #>> ISelect<<#=NewStr #>>.WithSql(<#=string.Join(",", WithSql) #>, object parms) + { + this.AsTable((type, old) => + { + <#=AsTable.ToString() #> + return old; + }); + if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject($"<#=string.Join(";\\r\\n", GetDbParamtersByObject) #>", parms)); + return this; + } + + double ISelect<<#=NewStr #>>.Avg(Expression, TMember>> column) + { + if (column == null) return default(double); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalAvg(column?.Body); + } + + ISelectGrouping>> ISelect<<#=NewStr #>>.GroupBy(Expression, TKey>> exp) + { + if (exp == null) return this.InternalGroupBy>>(exp?.Body); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.InternalGroupBy>>(exp?.Body); + } + + TMember ISelect<<#=NewStr #>>.Max(Expression, TMember>> column) + { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMax(column?.Body); + } + + TMember ISelect<<#=NewStr #>>.Min(Expression, TMember>> column) + { + if (column == null) return default(TMember); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMin(column?.Body); + } + + ISelect<<#=NewStr #>> ISelect<<#=NewStr #>>.OrderBy(Expression, TMember>> column) + { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalOrderBy(column?.Body); + } + + ISelect<<#=NewStr #>> ISelect<<#=NewStr #>>.OrderByDescending(Expression, TMember>> column) + { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalOrderByDescending(column?.Body); + } + + ISelect<<#=NewStr #>> ISelect<<#=NewStr #>>.OrderByIf(bool condition, Expression, TMember>> column, bool descending) + { + if (condition == false || column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return descending ? this.InternalOrderByDescending(column?.Body) : this.InternalOrderBy(column?.Body); + } + + decimal ISelect<<#=NewStr #>>.Sum(Expression, TMember>> column) + { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalSum(column?.Body); + } + + TReturn ISelect<<#=NewStr #>>.ToAggregate(Expression, TReturn>> select) + { + if (select == null) return default(TReturn); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToAggregate(select?.Body); + } + ISelect<<#=NewStr #>> ISelect<<#=NewStr #>>.Aggregate(Expression, TReturn>> select, out TReturn result) + { + result = (this as ISelect<<#=NewStr #>>).ToAggregate(select); + return this; + } + + List ISelect<<#=NewStr #>>.ToList(Expression, TReturn>> select) + { + if (select == null) return this.InternalToList(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToList(select?.Body); + } + + List ISelect<<#=NewStr #>>.ToList() => (this as ISelect<<#=NewStr #>>).ToList(GetToListDtoSelector()); + Expression, TDto>> GetToListDtoSelector() + { + return Expression.Lambda, TDto>>( + typeof(TDto).InternalNewExpression(), + _tables[0].Parameter ?? <#=string.Join(",", GetToListDtoSelector) #>); + } + + public void ToChunk(Expression, TReturn>> select, int size, Action>> done) + { + if (select == null || done == null) return; + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + this.InternalToChunk(select.Body, size, done); + } + + DataTable ISelect<<#=NewStr #>>.ToDataTable(Expression, TReturn>> select) + { + if (select == null) return this.InternalToDataTable(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToDataTable(select?.Body); + } + + int ISelect<<#=NewStr #>>.InsertInto(string tableName, Expression, TTargetEntity>> select) + { + if (select == null) return this.InternalInsertInto(tableName, select); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalInsertInto(tableName, select?.Body); + } + + string ISelect<<#=NewStr #>>.ToSql(Expression, TReturn>> select, FieldAliasOptions fieldAlias) + { + if (select == null) return this.InternalToSql(select?.Body, fieldAlias); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToSql(select?.Body, fieldAlias); + } + + ISelect<<#=NewStr #>> ISelect<<#=NewStr #>>.LeftJoin(Expression, bool>> exp) + { + if (exp == null) return this.InternalJoin(exp?.Body, SelectTableInfoType.LeftJoin); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.InternalJoin(exp?.Body, SelectTableInfoType.LeftJoin); + } + + ISelect<<#=NewStr #>> ISelect<<#=NewStr #>>.InnerJoin(Expression, bool>> exp) + { + if (exp == null) return this.InternalJoin(exp?.Body, SelectTableInfoType.LeftJoin); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.InternalJoin(exp?.Body, SelectTableInfoType.InnerJoin); + } + + ISelect<<#=NewStr #>> ISelect<<#=NewStr #>>.RightJoin(Expression, bool>> exp) + { + if (exp == null) return this.InternalJoin(exp?.Body, SelectTableInfoType.LeftJoin); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.InternalJoin(exp?.Body, SelectTableInfoType.RightJoin); + } + + ISelect<<#=NewStr #>> ISelect<<#=NewStr #>>.Where(Expression, bool>> exp) + { + if (exp == null) return this.Where(null); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)); + } + + ISelect<<#=NewStr #>> ISelect<<#=NewStr #>>.WhereIf(bool condition, Expression, bool>> exp) + { + if (condition == false || exp == null) return this; + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)); + } + + bool ISelect<<#=NewStr #>>.Any(Expression, bool>> exp) + { + if (exp == null) return this.Any(); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + var oldwhere = _where.ToString(); + var ret = this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).Any(); + _where.Clear().Append(oldwhere); + return ret; + } + + TReturn ISelect<<#=NewStr #>>.ToOne(Expression, TReturn>> select) => (this as ISelect<<#=NewStr #>>).Limit(1).ToList(select).FirstOrDefault(); + TReturn ISelect<<#=NewStr #>>.First(Expression, TReturn>> select) => (this as ISelect<<#=NewStr #>>).Limit(1).ToList(select).FirstOrDefault(); + TDto ISelect<<#=NewStr #>>.First() => (this as ISelect<<#=NewStr #>>).Limit(1).ToList().FirstOrDefault(); + + + + + + #region HzyTuple 元组 + + double ISelect<<#=NewStr #>>.Avg(Expression>, TMember>> column) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); + return (this as ISelect<<#=NewStr #>>).Avg((Expression, TMember>>)expModify); + } + + ISelectGrouping>> ISelect<<#=NewStr #>>.GroupBy(Expression>, TKey>> exp) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(exp, _tables); + return (this as ISelect<<#=NewStr #>>).GroupBy((Expression, TKey>>)expModify); + } + + TMember ISelect<<#=NewStr #>>.Max(Expression>, TMember>> column) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); + return (this as ISelect<<#=NewStr #>>).Max((Expression, TMember>>)expModify); + } + + TMember ISelect<<#=NewStr #>>.Min(Expression>, TMember>> column) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); + return (this as ISelect<<#=NewStr #>>).Min((Expression, TMember>>)expModify); + } + + ISelect<<#=NewStr #>> ISelect<<#=NewStr #>>.OrderBy(Expression>, TMember>> column) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); + return (this as ISelect<<#=NewStr #>>).OrderBy((Expression, TMember>>)expModify); + } + + ISelect<<#=NewStr #>> ISelect<<#=NewStr #>>.OrderByDescending(Expression>, TMember>> column) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); + return (this as ISelect<<#=NewStr #>>).OrderByDescending((Expression, TMember>>)expModify); + } + + ISelect<<#=NewStr #>> ISelect<<#=NewStr #>>.OrderByIf(bool condition, Expression>, TMember>> column, bool descending) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); + return (this as ISelect<<#=NewStr #>>).OrderByIf(condition,(Expression, TMember>>)expModify,descending); + } + + decimal ISelect<<#=NewStr #>>.Sum(Expression>, TMember>> column) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); + return (this as ISelect<<#=NewStr #>>).Sum((Expression, TMember>>)expModify); + } + + List ISelect<<#=NewStr #>>.ToList(Expression>, TReturn>> select) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); + return (this as ISelect<<#=NewStr #>>).ToList((Expression, TReturn>>)expModify); + } + + public void ToChunk(Expression>, TReturn>> select, int size, Action>> done) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); + (this as ISelect<<#=NewStr #>>).ToChunk((Expression, TReturn>>)expModify,size,done); + } + + DataTable ISelect<<#=NewStr #>>.ToDataTable(Expression>, TReturn>> select) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); + return (this as ISelect<<#=NewStr #>>).ToDataTable((Expression, TReturn>>)expModify); + } + + int ISelect<<#=NewStr #>>.InsertInto(string tableName, Expression>, TTargetEntity>> select) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); + return (this as ISelect<<#=NewStr #>>).InsertInto(tableName,(Expression, TTargetEntity>>)expModify); + } + + string ISelect<<#=NewStr #>>.ToSql(Expression>, TReturn>> select, FieldAliasOptions fieldAlias) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); + return (this as ISelect<<#=NewStr #>>).ToSql((Expression, TReturn>>)expModify,fieldAlias); + } + + ISelect<<#=NewStr #>> ISelect<<#=NewStr #>>.LeftJoin(Expression>, bool>> exp) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(exp, _tables); + return (this as ISelect<<#=NewStr #>>).LeftJoin((Expression, bool>>)expModify); + } + + ISelect<<#=NewStr #>> ISelect<<#=NewStr #>>.InnerJoin(Expression>, bool>> exp) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(exp, _tables); + return (this as ISelect<<#=NewStr #>>).InnerJoin((Expression, bool>>)expModify); + } + + ISelect<<#=NewStr #>> ISelect<<#=NewStr #>>.RightJoin(Expression>, bool>> exp) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(exp, _tables); + return (this as ISelect<<#=NewStr #>>).RightJoin((Expression, bool>>)expModify); + } + + ISelect<<#=NewStr #>> ISelect<<#=NewStr #>>.Where(Expression>, bool>> exp) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(exp, _tables); + return (this as ISelect<<#=NewStr #>>).Where((Expression, bool>>)expModify); + } + + ISelect<<#=NewStr #>> ISelect<<#=NewStr #>>.WhereIf(bool condition, Expression>, bool>> exp) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(exp, _tables); + return (this as ISelect<<#=NewStr #>>).WhereIf(condition,(Expression, bool>>)expModify); + } + + bool ISelect<<#=NewStr #>>.Any(Expression>, bool>> exp) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(exp, _tables); + return (this as ISelect<<#=NewStr #>>).Any((Expression, bool>>)expModify); + } + + TReturn ISelect<<#=NewStr #>>.ToOne(Expression>, TReturn>> select) + => (this as ISelect<<#=NewStr #>>).Limit(1).ToList(select).FirstOrDefault(); + TReturn ISelect<<#=NewStr #>>.First(Expression>, TReturn>> select) + => (this as ISelect<<#=NewStr #>>).Limit(1).ToList(select).FirstOrDefault(); + + #endregion + + + +#if net40 +#else + Task ISelect<<#=NewStr #>>.AvgAsync(Expression, TMember>> column) + { + if (column == null) return Task.FromResult(default(double)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalAvgAsync(column?.Body); + } + + Task ISelect<<#=NewStr #>>.MaxAsync(Expression, TMember>> column) + { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMaxAsync(column?.Body); + } + + Task ISelect<<#=NewStr #>>.MinAsync(Expression, TMember>> column) + { + if (column == null) return Task.FromResult(default(TMember)); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalMinAsync(column?.Body); + } + + Task ISelect<<#=NewStr #>>.SumAsync(Expression, TMember>> column) + { + if (column == null) this.InternalOrderBy(column?.Body); + for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a]; + return this.InternalSumAsync(column?.Body); + } + + Task ISelect<<#=NewStr #>>.ToAggregateAsync(Expression, TReturn>> select) + { + if (select == null) return Task.FromResult(default(TReturn)); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToAggregateAsync(select?.Body); + } + + Task> ISelect<<#=NewStr #>>.ToListAsync(Expression, TReturn>> select) + { + if (select == null) return this.InternalToListAsync(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToListAsync(select?.Body); + } + Task> ISelect<<#=NewStr #>>.ToListAsync() => (this as ISelect<<#=NewStr #>>).ToListAsync(GetToListDtoSelector()); + + Task ISelect<<#=NewStr #>>.ToDataTableAsync(Expression, TReturn>> select) + { + if (select == null) return this.InternalToDataTableAsync(select?.Body); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalToDataTableAsync(select?.Body); + } + + Task ISelect<<#=NewStr #>>.InsertIntoAsync(string tableName, Expression, TTargetEntity>> select) + { + if (select == null) return this.InternalInsertIntoAsync(tableName, select); + for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a]; + return this.InternalInsertIntoAsync(tableName, select?.Body); + } + + async Task ISelect<<#=NewStr #>>.AnyAsync(Expression, bool>> exp) + { + if (exp == null) return await this.AnyAsync(); + for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a]; + var oldwhere = _where.ToString(); + var ret = await this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereGlobalFilter, _params)).AnyAsync(); + _where.Clear().Append(oldwhere); + return ret; + } + + async Task ISelect<<#=NewStr #>>.ToOneAsync(Expression, TReturn>> select) => (await (this as ISelect<<#=NewStr #>>).Limit(1).ToListAsync(select)).FirstOrDefault(); + async Task ISelect<<#=NewStr #>>.FirstAsync(Expression, TReturn>> select) => (await (this as ISelect<<#=NewStr #>>).Limit(1).ToListAsync(select)).FirstOrDefault(); + async Task ISelect<<#=NewStr #>>.FirstAsync() => (await (this as ISelect<<#=NewStr #>>).Limit(1).ToListAsync()).FirstOrDefault(); + + + + + #region HzyTuple 元组 + + Task ISelect<<#=NewStr #>>.AvgAsync(Expression>, TMember>> column) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); + return (this as ISelect<<#=NewStr #>>).AvgAsync((Expression, TMember>>)expModify); + } + + Task ISelect<<#=NewStr #>>.MaxAsync(Expression>, TMember>> column) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); + return (this as ISelect<<#=NewStr #>>).MaxAsync((Expression, TMember>>)expModify); + } + + Task ISelect<<#=NewStr #>>.MinAsync(Expression>, TMember>> column) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); + return (this as ISelect<<#=NewStr #>>).MinAsync((Expression, TMember>>)expModify); + } + + Task ISelect<<#=NewStr #>>.SumAsync(Expression>, TMember>> column) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(column, _tables); + return (this as ISelect<<#=NewStr #>>).SumAsync((Expression, TMember>>)expModify); + } + + Task> ISelect<<#=NewStr #>>.ToListAsync(Expression>, TReturn>> select) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); + return (this as ISelect<<#=NewStr #>>).ToListAsync((Expression, TReturn>>)expModify); + } + + Task ISelect<<#=NewStr #>>.ToDataTableAsync(Expression>, TReturn>> select) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); + return (this as ISelect<<#=NewStr #>>).ToDataTableAsync((Expression, TReturn>>)expModify); + } + + Task ISelect<<#=NewStr #>>.InsertIntoAsync(string tableName, Expression>, TTargetEntity>> select) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(select, _tables); + return (this as ISelect<<#=NewStr #>>).InsertIntoAsync(tableName,(Expression, TTargetEntity>>)expModify); + } + + async Task ISelect<<#=NewStr #>>.AnyAsync(Expression>, bool>> exp) + { + var expModify = new CommonExpression.ReplaceHzyTupleToMultiParam().Modify(exp, _tables); + return await (this as ISelect<<#=NewStr #>>).AnyAsync((Expression, bool>>)expModify); + } + + async Task ISelect<<#=NewStr #>>.ToOneAsync(Expression>, TReturn>> select) + => (await (this as ISelect<<#=NewStr #>>).Limit(1).ToListAsync(select)).FirstOrDefault(); + async Task ISelect<<#=NewStr #>>.FirstAsync(Expression>, TReturn>> select) + => (await (this as ISelect<<#=NewStr #>>).Limit(1).ToListAsync(select)).FirstOrDefault(); + + + #endregion + +#endif + } + + + <# + } #> +} + + +<# + } #> \ No newline at end of file