diff --git a/Examples/base_entity/Program.cs b/Examples/base_entity/Program.cs index 3056d9fe9..1efd22956 100644 --- a/Examples/base_entity/Program.cs +++ b/Examples/base_entity/Program.cs @@ -581,9 +581,9 @@ static void Main(string[] args) //.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3;TrustServerCertificate=true") //.UseAdoConnectionPool(false) - //.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=127.0.0.1;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=2") + .UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=127.0.0.1;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=2") ////.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=127.0.0.1;Port=5432;Username=postgres;Password=123456;Database=toc;Pooling=true;Maximum Pool Size=2") - //.UseNameConvert(FreeSql.Internal.NameConvertType.ToLower) + .UseNameConvert(FreeSql.Internal.NameConvertType.ToLower) //.UseConnectionString(FreeSql.DataType.Oracle, "user id=user1;password=123456;data source=//127.0.0.1:1521/XE;Pooling=true;Max Pool Size=2") //.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper) @@ -619,6 +619,53 @@ static void Main(string[] args) BaseEntity.Initialization(fsql, () => _asyncUow.Value); #endregion + + var dbpars = new List(); + + var a1id1 = Guid.NewGuid(); + var a1id2 = Guid.NewGuid(); + //fsql.CodeFirst.IsGenerateCommandParameterWithLambda = true; + var sql1a0 = fsql.Select() + .WithParameters(dbpars) + .Where(a => a.Id == a1id1) + .OrderBy(a => a.Id) + + .UnionAll( + fsql.Select() + .WithParameters(dbpars) + .Where(a => a.Id == a1id2) + .OrderByDescending(a => a.Id), + + fsql.Select() + .WithParameters(dbpars) + .Where(a => a.Id == a1id2) + .OrderByDescending(a => a.Id) + ) + .Where(a => a.Id == a1id1 || a.Id == a1id2) + .ToList(); + var sql1a1 = fsql.Select() + .Where(a => a.Id == a1id1) + .UnionAll( + fsql.Select() + .Where(a => a.Id == a1id2) + ) + .Where(a => a.Id == a1id1 || a.Id == a1id2) + .ToList(); + var sql1a2 = fsql.Select() + .InnerJoin((a, b) => a.GroupId == b.Id) + .Where((a, b) => a.Id == a1id1) + .WithTempQuery((a, b) => new { user = a, group = b }) //匿名类型 + + .UnionAll( + fsql.Select() + .InnerJoin((a, b) => a.GroupId == b.Id) + .Where((a, b) => a.Id == a1id2) + .WithTempQuery((a, b) => new { user = a, group = b }) //匿名类型 + ) + + .Where(a => a.user.Id == a1id1 || a.user.Id == a1id2) + .ToList(); + fsql.Aop.AuditValue += (_, e) => { @@ -1676,48 +1723,6 @@ static void Main(string[] args) var sqlskdfj = fsql.Select().AsType(typeof(BBB)).ToSql(a => new CCC()); - var dbpars = new List(); - - var a1id1 = Guid.NewGuid(); - var a1id2 = Guid.NewGuid(); - //fsql.CodeFirst.IsGenerateCommandParameterWithLambda = true; - var sql1a0 = fsql.Select() - .WithParameters(dbpars) - .Where(a => a.Id == a1id1) - - .UnionAll( - fsql.Select() - .WithParameters(dbpars) - .Where(a => a.Id == a1id2), - - fsql.Select() - .WithParameters(dbpars) - .Where(a => a.Id == a1id2) - ) - .Where(a => a.Id == a1id1 || a.Id == a1id2) - .ToSql(); - var sql1a1 = fsql.Select() - .Where(a => a.Id == a1id1) - .UnionAll( - fsql.Select() - .Where(a => a.Id == a1id2) - ) - .Where(a => a.Id == a1id1 || a.Id == a1id2) - .ToSql(); - var sql1a2 = fsql.Select() - .InnerJoin((a, b) => a.GroupId == b.Id) - .Where((a, b) => a.Id == a1id1) - .WithTempQuery((a, b) => new { user = a, group = b }) //匿名类型 - - .UnionAll( - fsql.Select() - .InnerJoin((a, b) => a.GroupId == b.Id) - .Where((a, b) => a.Id == a1id2) - .WithTempQuery((a, b) => new { user = a, group = b }) //匿名类型 - ) - - .Where(a => a.user.Id == a1id1 || a.user.Id == a1id2) - .ToSql(); var ddlsql01 = fsql.CodeFirst.GetComparisonDDLStatements(); diff --git a/FreeSql/FreeSql.xml b/FreeSql/FreeSql.xml index 4ccbbef74..25f23c323 100644 --- a/FreeSql/FreeSql.xml +++ b/FreeSql/FreeSql.xml @@ -1087,93 +1087,6 @@ - - - 动态创建实体类型 - - - - - 配置Class - - 类名 - 类标记的特性[Table(Name = "xxx")] [Index(xxxx)] - - - - - 获取类型构建器,可作为要构建的Type来引用 - - - - - 配置属性 - - 属性名称 - 属性类型 - 属性标记的特性-支持多个 - - - - - 配置属性 - - 属性名称 - 属性类型 - 该属性是否重写父类属性 - 属性标记的特性-支持多个 - - - - - 配置属性 - - 属性名称 - 属性类型 - 该属性是否重写父类属性 - 属性默认值 - 属性标记的特性-支持多个 - - - - - 配置父类 - - 父类类型 - - - - - Override属性 - - - - - - Emit动态创建出Class - Type - - - - - - Emit动态创建出Class - Type,不附带获取TableInfo - - - - - - 首字母小写 - - - - - - - 首字母大写 - - - - 获取实体的主键值,以 "*|_,[,_|*" 分割,当任意一个主键属性无值时,返回 "" @@ -5897,28 +5810,6 @@ 对象池 - - - 动态构建Class Type - - - - - - 根据字典,创建 table 对应的实体对象 - - - - - - - - 根据实体对象,创建 table 对应的字典 - - - - - C#: that >= between && that <= and diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs index 67574b57e..6cbd034f5 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs @@ -271,9 +271,9 @@ public ISelect UnionAll(params ISelect[] querys) querys = querys?.Where(q => q != null).ToArray(); if (querys?.Any() != true) return this; var ret = (_orm as BaseDbProvider).CreateSelectProvider(null) as Select1Provider; - var sb = new StringBuilder().Append(LocalGetQuerySql(this)); + var sb = new StringBuilder().Append(this._select).Append(" * from (").Append(LocalGetQuerySql(this)).Append(") ftb"); foreach (var select2 in querys) - sb.Append(" \r\nUNION ALL \r\n").Append(LocalGetQuerySql(select2)); + sb.Append(" \r\nUNION ALL \r\nselect * from (").Append(LocalGetQuerySql(select2)).Append(") ftb"); ret.WithSql(sb.ToString()); sb.Clear(); ret._commandTimeout = _commandTimeout;