mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 09:15:27 +08:00 
			
		
		
		
	## v0.4.13
- 优化 MySql 日期类型精确至毫秒; - 增加 Distinct 查询前去重数据;
This commit is contained in:
		@@ -43,11 +43,11 @@ namespace FreeSql.Tests.MySql {
 | 
			
		||||
			sql = insert.AppendData(items).IgnoreColumns(a => a.CreateTime).ToSql();
 | 
			
		||||
			Assert.Equal("INSERT INTO `tb_topic`(`Clicks`, `Title`) VALUES(?Clicks_0, ?Title_0), (?Clicks_1, ?Title_1), (?Clicks_2, ?Title_2), (?Clicks_3, ?Title_3), (?Clicks_4, ?Title_4), (?Clicks_5, ?Title_5), (?Clicks_6, ?Title_6), (?Clicks_7, ?Title_7), (?Clicks_8, ?Title_8), (?Clicks_9, ?Title_9)", sql);
 | 
			
		||||
 | 
			
		||||
			sql = g.mysql.Insert<TestEnumInsertTb>().AppendData(new TestEnumInsertTb { type = TestEnumInserTbType.sum211 }).ToSql();
 | 
			
		||||
			sql = g.mysql.Insert<TestEnumInsertTb>().AppendData(new TestEnumInsertTb { type = TestEnumInserTbType.sum211, time = DateTime.Now }).ToSql();
 | 
			
		||||
			Assert.Equal("INSERT INTO `TestEnumInsertTb`(`type`, `time`) VALUES(?type_0, ?time_0)", sql);
 | 
			
		||||
 | 
			
		||||
			sql = g.mysql.Insert<TestEnumInsertTb>().AppendData(new TestEnumInsertTb { type = TestEnumInserTbType.sum211 }).NoneParameter().ToSql();
 | 
			
		||||
			Assert.Equal("INSERT INTO `TestEnumInsertTb`(`type`, `time`) VALUES('sum211', '0001-01-01 00:00:00')", sql);
 | 
			
		||||
			Assert.Equal("INSERT INTO `TestEnumInsertTb`(`type`, `time`) VALUES('sum211', '0001-01-01 00:00:00.000')", sql);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[Fact]
 | 
			
		||||
@@ -75,7 +75,7 @@ namespace FreeSql.Tests.MySql {
 | 
			
		||||
		[Fact]
 | 
			
		||||
		public void ExecuteAffrows() {
 | 
			
		||||
			var items = new List<Topic>();
 | 
			
		||||
			for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100 });
 | 
			
		||||
			for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100, CreateTime = DateTime.Now });
 | 
			
		||||
 | 
			
		||||
			Assert.Equal(1, insert.AppendData(items.First()).ExecuteAffrows());
 | 
			
		||||
			Assert.Equal(10, insert.AppendData(items).ExecuteAffrows());
 | 
			
		||||
 
 | 
			
		||||
@@ -735,6 +735,12 @@ namespace FreeSql.Tests.MySql {
 | 
			
		||||
			var sql22 = select.OrderBy(a => new Random().NextDouble()).Page(2, 10).ToList();
 | 
			
		||||
			var sql33 = select.OrderBy(a => new Random().NextDouble()).Page(3, 10).ToList();
 | 
			
		||||
		}
 | 
			
		||||
		[Fact]
 | 
			
		||||
		public void Distinct() {
 | 
			
		||||
			var t1 = select.Distinct().ToList(a => a.Title);
 | 
			
		||||
			var t2 = select.Distinct().Limit(10).ToList(a => a.Title);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[Fact]
 | 
			
		||||
		public void Sum() {
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -62,13 +62,13 @@ namespace FreeSql.Tests.MySql {
 | 
			
		||||
			Assert.Equal(TestEnumUpdateTbType.biggit, g.mysql.Select<TestEnumUpdateTb>().Where(a => a.id == id).First()?.type);
 | 
			
		||||
 | 
			
		||||
			sql = g.mysql.Insert<TestEnumUpdateTb>().NoneParameter().AppendData(new TestEnumUpdateTb { type = TestEnumUpdateTbType.sum211 }).ToSql().Replace("\r\n", "");
 | 
			
		||||
			Assert.Equal("INSERT INTO `TestEnumUpdateTb`(`type`, `time`) VALUES('sum211', '0001-01-01 00:00:00')", sql);
 | 
			
		||||
			Assert.Equal("INSERT INTO `TestEnumUpdateTb`(`type`, `time`) VALUES('sum211', '0001-01-01 00:00:00.000')", sql);
 | 
			
		||||
			id = g.mysql.Insert<TestEnumUpdateTb>().NoneParameter().AppendData(new TestEnumUpdateTb { type = TestEnumUpdateTbType.sum211 }).ExecuteIdentity();
 | 
			
		||||
			Assert.True(id > 0);
 | 
			
		||||
			Assert.Equal(TestEnumUpdateTbType.sum211, g.mysql.Select<TestEnumUpdateTb>().Where(a => a.id == id).First()?.type);
 | 
			
		||||
 | 
			
		||||
			sql = g.mysql.Update<TestEnumUpdateTb>().NoneParameter().SetSource(new TestEnumUpdateTb { type = TestEnumUpdateTbType.sum211 }).ToSql().Replace("\r\n", "");
 | 
			
		||||
			Assert.Equal("UPDATE `TestEnumUpdateTb` SET `type` = 'sum211', `time` = '0001-01-01 00:00:00' WHERE (`id` = 0)", sql);
 | 
			
		||||
			Assert.Equal("UPDATE `TestEnumUpdateTb` SET `type` = 'sum211', `time` = '0001-01-01 00:00:00.000' WHERE (`id` = 0)", sql);
 | 
			
		||||
			g.mysql.Update<TestEnumUpdateTb>().NoneParameter().SetSource(new TestEnumUpdateTb { id = (int)id, type = TestEnumUpdateTbType.biggit }).ExecuteAffrows();
 | 
			
		||||
			Assert.Equal(TestEnumUpdateTbType.biggit, g.mysql.Select<TestEnumUpdateTb>().Where(a => a.id == id).First()?.type);
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -50,7 +50,7 @@ namespace FreeSql.Tests.MySql {
 | 
			
		||||
  `testFieldFloat` FLOAT NOT NULL, 
 | 
			
		||||
  `testFieldDecimal` DECIMAL(10,2) NOT NULL, 
 | 
			
		||||
  `testFieldTimeSpan` TIME NOT NULL, 
 | 
			
		||||
  `testFieldDateTime` DATETIME NOT NULL, 
 | 
			
		||||
  `testFieldDateTime` DATETIME(3) NOT NULL, 
 | 
			
		||||
  `testFieldBytes` VARBINARY(255), 
 | 
			
		||||
  `testFieldString` VARCHAR(255), 
 | 
			
		||||
  `testFieldGuid` VARCHAR(36), 
 | 
			
		||||
@@ -67,7 +67,7 @@ namespace FreeSql.Tests.MySql {
 | 
			
		||||
  `testFieldFloatNullable` FLOAT, 
 | 
			
		||||
  `testFieldDecimalNullable` DECIMAL(10,2), 
 | 
			
		||||
  `testFieldTimeSpanNullable` TIME, 
 | 
			
		||||
  `testFieldDateTimeNullable` DATETIME, 
 | 
			
		||||
  `testFieldDateTimeNullable` DATETIME(3), 
 | 
			
		||||
  `testFieldGuidNullable` VARCHAR(36), 
 | 
			
		||||
  `testFieldPoint` POINT, 
 | 
			
		||||
  `testFieldLineString` LINESTRING, 
 | 
			
		||||
 
 | 
			
		||||
@@ -630,6 +630,12 @@ namespace FreeSql.Tests.Oracle {
 | 
			
		||||
			var sql22 = select.OrderBy(a => new Random().NextDouble()).Page(2, 10).ToList();
 | 
			
		||||
			var sql33 = select.OrderBy(a => new Random().NextDouble()).Page(3, 10).ToList();
 | 
			
		||||
		}
 | 
			
		||||
		[Fact]
 | 
			
		||||
		public void Distinct() {
 | 
			
		||||
			var t1 = select.Distinct().ToList(a => a.Title);
 | 
			
		||||
			var t2 = select.Distinct().Limit(10).ToList(a => a.Title);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[Fact]
 | 
			
		||||
		public void Sum() {
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -700,6 +700,12 @@ namespace FreeSql.Tests.PostgreSQL {
 | 
			
		||||
			var sql22 = select.OrderBy(a => new Random().NextDouble()).Page(2, 10).ToList();
 | 
			
		||||
			var sql33 = select.OrderBy(a => new Random().NextDouble()).Page(3, 10).ToList();
 | 
			
		||||
		}
 | 
			
		||||
		[Fact]
 | 
			
		||||
		public void Distinct() {
 | 
			
		||||
			var t1 = select.Distinct().ToList(a => a.Title);
 | 
			
		||||
			var t2 = select.Distinct().Limit(10).ToList(a => a.Title);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[Fact]
 | 
			
		||||
		public void Sum() {
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -632,6 +632,12 @@ namespace FreeSql.Tests.SqlServer {
 | 
			
		||||
			var sql22 = select.OrderBy(a => new Random().NextDouble()).Page(2, 10).ToList();
 | 
			
		||||
			var sql33 = select.OrderBy(a => new Random().NextDouble()).Page(3, 10).ToList();
 | 
			
		||||
		}
 | 
			
		||||
		[Fact]
 | 
			
		||||
		public void Distinct() {
 | 
			
		||||
			var t1 = select.Distinct().ToList(a => a.Title);
 | 
			
		||||
			var t2 = select.Distinct().Limit(10).ToList(a => a.Title);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[Fact]
 | 
			
		||||
		public void Sum() {
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -559,6 +559,12 @@ namespace FreeSql.Tests.Sqlite {
 | 
			
		||||
			var sql22 = select.OrderBy(a => new Random().NextDouble()).Page(2, 10).ToList();
 | 
			
		||||
			var sql33 = select.OrderBy(a => new Random().NextDouble()).Page(3, 10).ToList();
 | 
			
		||||
		}
 | 
			
		||||
		[Fact]
 | 
			
		||||
		public void Distinct() {
 | 
			
		||||
			var t1 = select.Distinct().ToList(a => a.Title);
 | 
			
		||||
			var t2 = select.Distinct().Limit(10).ToList(a => a.Title);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[Fact]
 | 
			
		||||
		public void Sum() {
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -69,6 +69,9 @@ namespace FreeSql.Tests.Sqlite {
 | 
			
		||||
 | 
			
		||||
			sql = update.Set(a => a.Id - incrv).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
 | 
			
		||||
			Assert.Equal("UPDATE \"tb_topic\" SET \"Id\" = \"Id\" - 10 WHERE (\"Id\" = 1)", sql);
 | 
			
		||||
 | 
			
		||||
			sql = update.Set(a => a.CreateTime.AddYears(1)).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
 | 
			
		||||
			Assert.Equal("UPDATE \"tb_topic\" SET \"CreateTime\" = datetime(\"CreateTime\",(1)||' years') WHERE (\"Id\" = 1)", sql);
 | 
			
		||||
		}
 | 
			
		||||
		[Fact]
 | 
			
		||||
		public void SetRaw() {
 | 
			
		||||
 
 | 
			
		||||
@@ -44,6 +44,8 @@ namespace FreeSql.Tests {
 | 
			
		||||
		[Fact]
 | 
			
		||||
		public void Test1() {
 | 
			
		||||
 | 
			
		||||
			var xxx = g.sqlite.Select<TestUser>().GroupBy(a => new { a.stringid }).ToList(a => a.Key.stringid);
 | 
			
		||||
 | 
			
		||||
			var tuser = g.sqlite.Select<TestUser>().Where(u => u.accname == "admin")
 | 
			
		||||
				.InnerJoin(a => a.LogOn.id == a.stringid).ToSql();
 | 
			
		||||
 | 
			
		||||
@@ -88,7 +90,7 @@ namespace FreeSql.Tests {
 | 
			
		||||
 | 
			
		||||
			var orderDetail1 = order.OrderDetails; //<2F><>һ<EFBFBD>η<EFBFBD><CEB7>ʣ<EFBFBD><CAA3><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD>ݿ<EFBFBD>
 | 
			
		||||
			var orderDetail2 = order.OrderDetails; //<2F>ڶ<EFBFBD><DAB6>η<EFBFBD><CEB7>ʣ<EFBFBD><CAA3><EFBFBD><EFBFBD><EFBFBD>
 | 
			
		||||
			var order1 = orderDetail1.FirstOrDefault(); //<2F><><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ⣬<DDBF><E2A3AC>Ϊ OrderDetails <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˸<EFBFBD><CBB8><EFBFBD><EFBFBD><EFBFBD>
 | 
			
		||||
			var order1 = orderDetail1.FirstOrDefault().Order; //<2F><><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ⣬<DDBF><E2A3AC>Ϊ OrderDetails <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˸<EFBFBD><CBB8><EFBFBD><EFBFBD><EFBFBD>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
			var queryable = g.mysql.Queryable<TestInfo>().Where(a => a.Id == 1).ToList();
 | 
			
		||||
 
 | 
			
		||||
@@ -182,9 +182,9 @@ namespace FreeSql.Extensions.EntityUtil {
 | 
			
		||||
		/// <summary>
 | 
			
		||||
		/// 使用新实体的值,复盖旧实体的值
 | 
			
		||||
		/// </summary>
 | 
			
		||||
		static ConcurrentDictionary<DataType, ConcurrentDictionary<Type, Action<object, object>>> _dicCopyNewValueToEntity = new ConcurrentDictionary<DataType, ConcurrentDictionary<Type, Action<object, object>>>();
 | 
			
		||||
		static ConcurrentDictionary<DataType, ConcurrentDictionary<Type, Action<object, object>>> _dicMapEntityValue = new ConcurrentDictionary<DataType, ConcurrentDictionary<Type, Action<object, object>>>();
 | 
			
		||||
		public static void MapEntityValue<TEntity>(this IFreeSql orm, TEntity from, TEntity to) {
 | 
			
		||||
			var func = _dicCopyNewValueToEntity.GetOrAdd(orm.Ado.DataType, dt => new ConcurrentDictionary<Type, Action<object, object>>()).GetOrAdd(typeof(TEntity), t => {
 | 
			
		||||
			var func = _dicMapEntityValue.GetOrAdd(orm.Ado.DataType, dt => new ConcurrentDictionary<Type, Action<object, object>>()).GetOrAdd(typeof(TEntity), t => {
 | 
			
		||||
				var _table = orm.CodeFirst.GetTableByEntity(t);
 | 
			
		||||
				var parm1 = Expression.Parameter(typeof(object));
 | 
			
		||||
				var parm2 = Expression.Parameter(typeof(object));
 | 
			
		||||
@@ -216,6 +216,35 @@ namespace FreeSql.Extensions.EntityUtil {
 | 
			
		||||
			func(from, to);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		static ConcurrentDictionary<DataType, ConcurrentDictionary<Type, Action<object, object>>> _dicMapEntityKeyValue = new ConcurrentDictionary<DataType, ConcurrentDictionary<Type, Action<object, object>>>();
 | 
			
		||||
		/// <summary>
 | 
			
		||||
		/// 使用新实体的主键值,复盖旧实体的主键值
 | 
			
		||||
		/// </summary>
 | 
			
		||||
		public static void MapEntityKeyValue<TEntity>(this IFreeSql orm, TEntity from, TEntity to) {
 | 
			
		||||
			var func = _dicMapEntityKeyValue.GetOrAdd(orm.Ado.DataType, dt => new ConcurrentDictionary<Type, Action<object, object>>()).GetOrAdd(typeof(TEntity), t => {
 | 
			
		||||
				var _table = orm.CodeFirst.GetTableByEntity(t);
 | 
			
		||||
				var pks = _table.Primarys;
 | 
			
		||||
				var parm1 = Expression.Parameter(typeof(object));
 | 
			
		||||
				var parm2 = Expression.Parameter(typeof(object));
 | 
			
		||||
				var var1Parm = Expression.Variable(t);
 | 
			
		||||
				var var2Parm = Expression.Variable(t);
 | 
			
		||||
				var exps = new List<Expression>(new Expression[] {
 | 
			
		||||
					Expression.Assign(var1Parm, Expression.TypeAs(parm1, t)),
 | 
			
		||||
					Expression.Assign(var2Parm, Expression.TypeAs(parm2, t))
 | 
			
		||||
				});
 | 
			
		||||
				foreach (var pk in pks) {
 | 
			
		||||
					exps.Add(
 | 
			
		||||
						Expression.Assign(
 | 
			
		||||
							Expression.MakeMemberAccess(var2Parm, _table.Properties[pk.CsName]),
 | 
			
		||||
							Expression.MakeMemberAccess(var1Parm, _table.Properties[pk.CsName])
 | 
			
		||||
						)
 | 
			
		||||
					);
 | 
			
		||||
				}
 | 
			
		||||
				return Expression.Lambda<Action<object, object>>(Expression.Block(new[] { var1Parm, var2Parm }, exps), new[] { parm1, parm2 }).Compile();
 | 
			
		||||
			});
 | 
			
		||||
			func(from, to);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		static ConcurrentDictionary<DataType, ConcurrentDictionary<Type, Action<object, long>>> _dicSetEntityIdentityValueWithPrimary = new ConcurrentDictionary<DataType, ConcurrentDictionary<Type, Action<object, long>>>();
 | 
			
		||||
		/// <summary>
 | 
			
		||||
		/// 设置实体中主键内的自增字段值(若存在)
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
	<PropertyGroup>
 | 
			
		||||
		<TargetFramework>netstandard2.0</TargetFramework>
 | 
			
		||||
		<Version>0.4.12</Version>
 | 
			
		||||
		<Version>0.4.13</Version>
 | 
			
		||||
		<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
 | 
			
		||||
		<Authors>YeXiangQin</Authors>
 | 
			
		||||
		<Description>FreeSql is the most convenient ORM in dotnet. It supports Mysql, Postgresql, SqlServer, Oracle and Sqlite.</Description>
 | 
			
		||||
 
 | 
			
		||||
@@ -242,5 +242,11 @@ namespace FreeSql {
 | 
			
		||||
		/// <param name="pageSize">每页多少</param>
 | 
			
		||||
		/// <returns></returns>
 | 
			
		||||
		TSelect Page(int pageIndex, int pageSize);
 | 
			
		||||
 | 
			
		||||
		/// <summary>
 | 
			
		||||
		/// 查询数据前,去重
 | 
			
		||||
		/// </summary>
 | 
			
		||||
		/// <returns></returns>
 | 
			
		||||
		TSelect Distinct();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -30,6 +30,7 @@ namespace FreeSql.Internal.CommonProvider {
 | 
			
		||||
		protected DbTransaction _transaction;
 | 
			
		||||
		protected DbConnection _connection;
 | 
			
		||||
		protected Action<object> _trackToList;
 | 
			
		||||
		protected bool _distinct;
 | 
			
		||||
 | 
			
		||||
		internal static void CopyData(Select0Provider<TSelect, T1> from, object to, ReadOnlyCollection<ParameterExpression> lambParms) {
 | 
			
		||||
			var toType = to?.GetType();
 | 
			
		||||
@@ -64,6 +65,7 @@ namespace FreeSql.Internal.CommonProvider {
 | 
			
		||||
			toType.GetField("_transaction", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(to, from._transaction);
 | 
			
		||||
			toType.GetField("_connection", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(to, from._connection);
 | 
			
		||||
			toType.GetField("_trackToList", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(to, from._trackToList);
 | 
			
		||||
			toType.GetField("_distinct", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(to, from._distinct);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public Select0Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) {
 | 
			
		||||
@@ -204,6 +206,11 @@ namespace FreeSql.Internal.CommonProvider {
 | 
			
		||||
		}
 | 
			
		||||
		public TSelect Take(int limit) => this.Limit(limit) as TSelect;
 | 
			
		||||
 | 
			
		||||
		public TSelect Distinct() {
 | 
			
		||||
			_distinct = true;
 | 
			
		||||
			return this as TSelect;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public DataTable ToDataTable(string field = null) {
 | 
			
		||||
			var sql = this.ToSql(field);
 | 
			
		||||
			if (_cache.seconds > 0 && string.IsNullOrEmpty(_cache.key)) _cache.key = sql;
 | 
			
		||||
 
 | 
			
		||||
@@ -10,13 +10,15 @@ namespace FreeSql.MySql.Curd {
 | 
			
		||||
 | 
			
		||||
	class MySqlSelect<T1> : FreeSql.Internal.CommonProvider.Select1Provider<T1> where T1 : class {
 | 
			
		||||
 | 
			
		||||
		internal static string ToSqlStatic(CommonUtils _commonUtils, string _select, string field, StringBuilder _join, StringBuilder _where, string _groupby, string _having, string _orderby, int _skip, int _limit, List<SelectTableInfo> _tables, Func<Type, string, string> tableRuleInvoke, IFreeSql _orm) {
 | 
			
		||||
		internal static string ToSqlStatic(CommonUtils _commonUtils, string _select, bool _distinct, string field, StringBuilder _join, StringBuilder _where, string _groupby, string _having, string _orderby, int _skip, int _limit, List<SelectTableInfo> _tables, Func<Type, string, string> tableRuleInvoke, IFreeSql _orm) {
 | 
			
		||||
			if (_orm.CodeFirst.IsAutoSyncStructure)
 | 
			
		||||
				_orm.CodeFirst.SyncStructure(_tables.Select(a => a.Table.Type).ToArray());
 | 
			
		||||
 | 
			
		||||
			var sb = new StringBuilder();
 | 
			
		||||
			var sbnav = new StringBuilder();
 | 
			
		||||
			sb.Append(_select).Append(field).Append(" \r\nFROM ");
 | 
			
		||||
			sb.Append(_select);
 | 
			
		||||
			if (_distinct) sb.Append("DISTINCT ");
 | 
			
		||||
			sb.Append(field).Append(" \r\nFROM ");
 | 
			
		||||
			var tbsjoin = _tables.Where(a => a.Type != SelectTableInfoType.From).ToArray();
 | 
			
		||||
			var tbsfrom = _tables.Where(a => a.Type == SelectTableInfoType.From).ToArray();
 | 
			
		||||
			for (var a = 0; a < tbsfrom.Length; a++) {
 | 
			
		||||
@@ -84,38 +86,38 @@ namespace FreeSql.MySql.Curd {
 | 
			
		||||
		public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8> From<T2, T3, T4, T5, T6, T7, T8>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp?.Body); var ret = new MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8>(_orm, _commonUtils, _commonExpression, null); MySqlSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
 | 
			
		||||
		public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> From<T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp?.Body); var ret = new MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>(_orm, _commonUtils, _commonExpression, null); MySqlSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
 | 
			
		||||
		public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> From<T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp?.Body); var ret = new MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(_orm, _commonUtils, _commonExpression, null); MySqlSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
 | 
			
		||||
		public override string ToSql(string field = null) => ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class MySqlSelect<T1, T2, T3> : FreeSql.Internal.CommonProvider.Select3Provider<T1, T2, T3> where T1 : class where T2 : class where T3 : class {
 | 
			
		||||
		public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => MySqlSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => MySqlSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class MySqlSelect<T1, T2, T3, T4> : FreeSql.Internal.CommonProvider.Select4Provider<T1, T2, T3, T4> where T1 : class where T2 : class where T3 : class where T4 : class {
 | 
			
		||||
		public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => MySqlSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => MySqlSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class MySqlSelect<T1, T2, T3, T4, T5> : FreeSql.Internal.CommonProvider.Select5Provider<T1, T2, T3, T4, T5> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class {
 | 
			
		||||
		public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => MySqlSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => MySqlSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class MySqlSelect<T1, T2, T3, T4, T5, T6> : FreeSql.Internal.CommonProvider.Select6Provider<T1, T2, T3, T4, T5, T6> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class {
 | 
			
		||||
		public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => MySqlSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => MySqlSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class MySqlSelect<T1, T2, T3, T4, T5, T6, T7> : FreeSql.Internal.CommonProvider.Select7Provider<T1, T2, T3, T4, T5, T6, T7> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class {
 | 
			
		||||
		public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => MySqlSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => MySqlSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8> : FreeSql.Internal.CommonProvider.Select8Provider<T1, T2, T3, T4, T5, T6, T7, T8> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class {
 | 
			
		||||
		public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => MySqlSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => MySqlSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> : FreeSql.Internal.CommonProvider.Select9Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class {
 | 
			
		||||
		public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => MySqlSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => MySqlSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> : FreeSql.Internal.CommonProvider.Select10Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> where T1 : class 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 {
 | 
			
		||||
		public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => MySqlSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => MySqlSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -35,7 +35,7 @@ namespace FreeSql.MySql {
 | 
			
		||||
			else if (decimal.TryParse(string.Concat(param), out var trydec))
 | 
			
		||||
				return param;
 | 
			
		||||
			else if (param is DateTime || param is DateTime?)
 | 
			
		||||
				return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss"), "'");
 | 
			
		||||
				return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
 | 
			
		||||
			else if (param is TimeSpan || param is TimeSpan?)
 | 
			
		||||
				return ((TimeSpan)param).Ticks / 10;
 | 
			
		||||
			else if (param is MygisGeometry)
 | 
			
		||||
 
 | 
			
		||||
@@ -49,7 +49,7 @@ namespace FreeSql.MySql {
 | 
			
		||||
				{ typeof(decimal).FullName,  (MySqlDbType.Decimal, "decimal", "decimal(10,2) NOT NULL", false, false, 0) },{ typeof(decimal?).FullName,  (MySqlDbType.Decimal, "decimal", "decimal(10,2)", false, true, null) },
 | 
			
		||||
 | 
			
		||||
				{ typeof(TimeSpan).FullName,  (MySqlDbType.Time, "time","time NOT NULL", false, false, 0) },{ typeof(TimeSpan?).FullName,  (MySqlDbType.Time, "time", "time",false, true, null) },
 | 
			
		||||
				{ typeof(DateTime).FullName,  (MySqlDbType.DateTime, "datetime", "datetime NOT NULL", false, false, new DateTime(1970,1,1)) },{ typeof(DateTime?).FullName,  (MySqlDbType.DateTime, "datetime", "datetime", false, true, null) },
 | 
			
		||||
				{ typeof(DateTime).FullName,  (MySqlDbType.DateTime, "datetime(3)", "datetime(3) NOT NULL", false, false, new DateTime(1970,1,1)) },{ typeof(DateTime?).FullName,  (MySqlDbType.DateTime, "datetime(3)", "datetime(3)", false, true, null) },
 | 
			
		||||
 | 
			
		||||
				{ typeof(byte[]).FullName,  (MySqlDbType.VarBinary, "varbinary", "varbinary(255)", false, null, new byte[0]) },
 | 
			
		||||
				{ typeof(string).FullName,  (MySqlDbType.VarChar, "varchar", "varchar(255)", false, null, "") },
 | 
			
		||||
@@ -163,12 +163,16 @@ case when locate('auto_increment', a.extra) > 0 then 1 else 0 end 'is_identity'
 | 
			
		||||
from information_schema.columns a
 | 
			
		||||
where a.table_schema in ({0}) and a.table_name in ({1})".FormatMySql(tboldname ?? tbname);
 | 
			
		||||
					var ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
 | 
			
		||||
					var tbstruct = ds.ToDictionary(a => string.Concat(a[0]), a => new {
 | 
			
		||||
					var tbstruct = ds.ToDictionary(a => string.Concat(a[0]), a => {
 | 
			
		||||
						var a1 = string.Concat(a[1]);
 | 
			
		||||
						if (a1 == "datetime") a1 = string.Concat(a1, "(0)");
 | 
			
		||||
						return new {
 | 
			
		||||
							column = string.Concat(a[0]),
 | 
			
		||||
						sqlType = string.Concat(a[1]),
 | 
			
		||||
							sqlType = a1,
 | 
			
		||||
							is_nullable = string.Concat(a[2]) == "1",
 | 
			
		||||
							is_identity = string.Concat(a[3]) == "1",
 | 
			
		||||
							is_unsigned = string.Concat(a[1]).EndsWith(" unsigned")
 | 
			
		||||
						};
 | 
			
		||||
					}, StringComparer.CurrentCultureIgnoreCase);
 | 
			
		||||
 | 
			
		||||
					if (istmpatler == false) {
 | 
			
		||||
 
 | 
			
		||||
@@ -10,13 +10,14 @@ namespace FreeSql.Oracle.Curd {
 | 
			
		||||
 | 
			
		||||
	class OracleSelect<T1> : FreeSql.Internal.CommonProvider.Select1Provider<T1> where T1 : class {
 | 
			
		||||
 | 
			
		||||
		internal static string ToSqlStatic(CommonUtils _commonUtils, string _select, string field, StringBuilder _join, StringBuilder _where, string _groupby, string _having, string _orderby, int _skip, int _limit, List<SelectTableInfo> _tables, Func<Type, string, string> tableRuleInvoke, IFreeSql _orm) {
 | 
			
		||||
		internal static string ToSqlStatic(CommonUtils _commonUtils, string _select, bool _distinct, string field, StringBuilder _join, StringBuilder _where, string _groupby, string _having, string _orderby, int _skip, int _limit, List<SelectTableInfo> _tables, Func<Type, string, string> tableRuleInvoke, IFreeSql _orm) {
 | 
			
		||||
			if (_orm.CodeFirst.IsAutoSyncStructure)
 | 
			
		||||
				_orm.CodeFirst.SyncStructure(_tables.Select(a => a.Table.Type).ToArray());
 | 
			
		||||
 | 
			
		||||
			var sb = new StringBuilder();
 | 
			
		||||
			var sbnav = new StringBuilder();
 | 
			
		||||
			sb.Append(_select);
 | 
			
		||||
			if (_distinct) sb.Append("DISTINCT ");
 | 
			
		||||
			sb.Append(field);
 | 
			
		||||
			if (string.IsNullOrEmpty(_orderby) && _skip > 0) sb.Append(", ROWNUM AS \"__rownum__\"");
 | 
			
		||||
			sb.Append(" \r\nFROM ");
 | 
			
		||||
@@ -97,38 +98,38 @@ namespace FreeSql.Oracle.Curd {
 | 
			
		||||
		public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8> From<T2, T3, T4, T5, T6, T7, T8>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp?.Body); var ret = new OracleSelect<T1, T2, T3, T4, T5, T6, T7, T8>(_orm, _commonUtils, _commonExpression, null); OracleSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
 | 
			
		||||
		public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> From<T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp?.Body); var ret = new OracleSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>(_orm, _commonUtils, _commonExpression, null); OracleSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
 | 
			
		||||
		public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> From<T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp?.Body); var ret = new OracleSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(_orm, _commonUtils, _commonExpression, null); OracleSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
 | 
			
		||||
		public override string ToSql(string field = null) => ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class OracleSelect<T1, T2, T3> : FreeSql.Internal.CommonProvider.Select3Provider<T1, T2, T3> where T1 : class where T2 : class where T3 : class {
 | 
			
		||||
		public OracleSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => OracleSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => OracleSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class OracleSelect<T1, T2, T3, T4> : FreeSql.Internal.CommonProvider.Select4Provider<T1, T2, T3, T4> where T1 : class where T2 : class where T3 : class where T4 : class {
 | 
			
		||||
		public OracleSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => OracleSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => OracleSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class OracleSelect<T1, T2, T3, T4, T5> : FreeSql.Internal.CommonProvider.Select5Provider<T1, T2, T3, T4, T5> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class {
 | 
			
		||||
		public OracleSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => OracleSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => OracleSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class OracleSelect<T1, T2, T3, T4, T5, T6> : FreeSql.Internal.CommonProvider.Select6Provider<T1, T2, T3, T4, T5, T6> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class {
 | 
			
		||||
		public OracleSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => OracleSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => OracleSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class OracleSelect<T1, T2, T3, T4, T5, T6, T7> : FreeSql.Internal.CommonProvider.Select7Provider<T1, T2, T3, T4, T5, T6, T7> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class {
 | 
			
		||||
		public OracleSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => OracleSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => OracleSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class OracleSelect<T1, T2, T3, T4, T5, T6, T7, T8> : FreeSql.Internal.CommonProvider.Select8Provider<T1, T2, T3, T4, T5, T6, T7, T8> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class {
 | 
			
		||||
		public OracleSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => OracleSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => OracleSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class OracleSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> : FreeSql.Internal.CommonProvider.Select9Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class {
 | 
			
		||||
		public OracleSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => OracleSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => OracleSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class OracleSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> : FreeSql.Internal.CommonProvider.Select10Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> where T1 : class 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 {
 | 
			
		||||
		public OracleSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => OracleSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => OracleSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										361
									
								
								FreeSql/Oracle/OracleDbFirst.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										361
									
								
								FreeSql/Oracle/OracleDbFirst.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,361 @@
 | 
			
		||||
//using FreeSql.DatabaseModel;
 | 
			
		||||
//using FreeSql.Internal;
 | 
			
		||||
//using System;
 | 
			
		||||
//using System.Collections.Generic;
 | 
			
		||||
//using System.Linq;
 | 
			
		||||
//using System.Text.RegularExpressions;
 | 
			
		||||
//using Oracle.ManagedDataAccess.Client;
 | 
			
		||||
//using System.Data;
 | 
			
		||||
 | 
			
		||||
//namespace FreeSql.Oracle {
 | 
			
		||||
//	class OracleDbFirst : IDbFirst {
 | 
			
		||||
//		IFreeSql _orm;
 | 
			
		||||
//		protected CommonUtils _commonUtils;
 | 
			
		||||
//		protected CommonExpression _commonExpression;
 | 
			
		||||
//		public OracleDbFirst(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression) {
 | 
			
		||||
//			_orm = orm;
 | 
			
		||||
//			_commonUtils = commonUtils;
 | 
			
		||||
//			_commonExpression = commonExpression;
 | 
			
		||||
//		}
 | 
			
		||||
 | 
			
		||||
//		public int GetDbType(DbColumnInfo column) => (int)GetSqlDbType(column);
 | 
			
		||||
//		OracleDbType GetSqlDbType(DbColumnInfo column) {
 | 
			
		||||
//			switch (column.DbTypeText.ToLower()) {
 | 
			
		||||
//				case "bit": return OracleDbType.Boolean;
 | 
			
		||||
//				case "tinyint": return OracleDbType.TinyInt;
 | 
			
		||||
//				case "smallint": return OracleDbType.SmallInt;
 | 
			
		||||
//				case "int": return OracleDbType.Int;
 | 
			
		||||
//				case "bigint": return OracleDbType.BigInt;
 | 
			
		||||
//				case "numeric":
 | 
			
		||||
//				case "decimal": return OracleDbType.Decimal;
 | 
			
		||||
//				case "smallmoney": return OracleDbType.SmallMoney;
 | 
			
		||||
//				case "money": return OracleDbType.Money;
 | 
			
		||||
//				case "float": return OracleDbType.Float;
 | 
			
		||||
//				case "real": return OracleDbType.Real;
 | 
			
		||||
//				case "date": return OracleDbType.Date;
 | 
			
		||||
//				case "datetime":
 | 
			
		||||
//				case "datetime2": return OracleDbType.DateTime;
 | 
			
		||||
//				case "datetimeoffset": return OracleDbType.DateTimeOffset;
 | 
			
		||||
//				case "smalldatetime": return OracleDbType.SmallDateTime;
 | 
			
		||||
//				case "time": return OracleDbType.Time;
 | 
			
		||||
//				case "char": return OracleDbType.Char;
 | 
			
		||||
//				case "varchar": return OracleDbType.VarChar;
 | 
			
		||||
//				case "text": return OracleDbType.Text;
 | 
			
		||||
//				case "nchar": return OracleDbType.NChar;
 | 
			
		||||
//				case "nvarchar": return OracleDbType.NVarChar;
 | 
			
		||||
//				case "ntext": return OracleDbType.NText;
 | 
			
		||||
//				case "binary": return OracleDbType.Binary;
 | 
			
		||||
//				case "varbinary": return OracleDbType.VarBinary;
 | 
			
		||||
//				case "image": return OracleDbType.Image;
 | 
			
		||||
//				case "timestamp": return OracleDbType.Timestamp;
 | 
			
		||||
//				case "uniqueidentifier": return OracleDbType.UniqueIdentifier;
 | 
			
		||||
//				default: return OracleDbType.Variant;
 | 
			
		||||
//			}
 | 
			
		||||
//		}
 | 
			
		||||
 | 
			
		||||
//		static readonly Dictionary<int, (string csConvert, string csParse, string csStringify, string csType, Type csTypeInfo, Type csNullableTypeInfo, string csTypeValue, string dataReaderMethod)> _dicDbToCs = new Dictionary<int, (string csConvert, string csParse, string csStringify, string csType, Type csTypeInfo, Type csNullableTypeInfo, string csTypeValue, string dataReaderMethod)>() {
 | 
			
		||||
//				{ (int)OracleDbType.Boolean, ("(bool?)", "{0} == \"1\"", "{0} == true ? \"1\" : \"0\"", "bool?", typeof(bool), typeof(bool?), "{0}.Value", "GetBoolean") },
 | 
			
		||||
 | 
			
		||||
//				{ (int)OracleDbType.TinyInt, ("(byte?)", "sbyte.Parse({0})", "{0}.ToString()", "sbyte?", typeof(sbyte), typeof(sbyte?), "{0}.Value", "GetByte") },
 | 
			
		||||
//				{ (int)OracleDbType.SmallInt, ("(short?)", "short.Parse({0})", "{0}.ToString()", "short?", typeof(short), typeof(short?), "{0}.Value", "GetInt16") },
 | 
			
		||||
//				{ (int)OracleDbType.Int, ("(int?)", "int.Parse({0})", "{0}.ToString()", "int?", typeof(int), typeof(int?), "{0}.Value", "GetInt32") },
 | 
			
		||||
//				{ (int)OracleDbType.BigInt, ("(long?)", "long.Parse({0})", "{0}.ToString()", "long?", typeof(long), typeof(long?), "{0}.Value", "GetInt64") },
 | 
			
		||||
 | 
			
		||||
//				{ (int)OracleDbType.SmallMoney, ("(decimal?)", "decimal.Parse({0})", "{0}.ToString()", "decimal?", typeof(decimal), typeof(decimal?), "{0}.Value", "GetDecimal") },
 | 
			
		||||
//				{ (int)OracleDbType.Money, ("(decimal?)", "decimal.Parse({0})", "{0}.ToString()", "decimal?", typeof(decimal), typeof(decimal?), "{0}.Value", "GetDecimal") },
 | 
			
		||||
//				{ (int)OracleDbType.Decimal, ("(decimal?)", "decimal.Parse({0})", "{0}.ToString()", "decimal?", typeof(decimal), typeof(decimal?), "{0}.Value", "GetDecimal") },
 | 
			
		||||
//				{ (int)OracleDbType.Float, ("(double?)", "double.Parse({0})", "{0}.ToString()", "double?", typeof(double), typeof(double?), "{0}.Value", "GetDouble") },
 | 
			
		||||
//				{ (int)OracleDbType.Real, ("(float?)", "float.Parse({0})", "{0}.ToString()", "float?", typeof(float), typeof(float?), "{0}.Value", "GetFloat") },
 | 
			
		||||
 | 
			
		||||
//				{ (int)OracleDbType.Time, ("(TimeSpan?)", "TimeSpan.Parse(double.Parse({0}))", "{0}.Ticks.ToString()", "TimeSpan?", typeof(TimeSpan), typeof(TimeSpan?), "{0}.Value", "GetValue") },
 | 
			
		||||
//				{ (int)OracleDbType.Date, ("(DateTime?)", "new DateTime(long.Parse({0}))", "{0}.Ticks.ToString()", "DateTime?", typeof(DateTime), typeof(DateTime?), "{0}.Value", "GetDateTime") },
 | 
			
		||||
//				{ (int)OracleDbType.DateTime, ("(DateTime?)", "new DateTime(long.Parse({0}))", "{0}.Ticks.ToString()", "DateTime?", typeof(DateTime), typeof(DateTime?), "{0}.Value", "GetDateTime") },
 | 
			
		||||
//				{ (int)OracleDbType.DateTime2, ("(DateTime?)", "new DateTime(long.Parse({0}))", "{0}.Ticks.ToString()", "DateTime?", typeof(DateTime), typeof(DateTime?), "{0}.Value", "GetDateTime") },
 | 
			
		||||
//				{ (int)OracleDbType.SmallDateTime, ("(DateTime?)", "new DateTime(long.Parse({0}))", "{0}.Ticks.ToString()", "DateTime?", typeof(DateTime), typeof(DateTime?), "{0}.Value", "GetDateTime") },
 | 
			
		||||
//				{ (int)OracleDbType.DateTimeOffset, ("(DateTimeOffset?)", "new DateTimeOffset(long.Parse({0}))", "{0}.Ticks.ToString()", "DateTime?", typeof(DateTimeOffset), typeof(DateTimeOffset?), "{0}.Value", "GetDateTimeOffset") },
 | 
			
		||||
 | 
			
		||||
//				{ (int)OracleDbType.Binary, ("(byte[])", "Convert.FromBase64String({0})", "Convert.ToBase64String({0})", "byte[]", typeof(byte[]), typeof(byte[]), "{0}", "GetValue") },
 | 
			
		||||
//				{ (int)OracleDbType.VarBinary, ("(byte[])", "Convert.FromBase64String({0})", "Convert.ToBase64String({0})", "byte[]", typeof(byte[]), typeof(byte[]), "{0}", "GetValue") },
 | 
			
		||||
//				{ (int)OracleDbType.Image, ("(byte[])", "Convert.FromBase64String({0})", "Convert.ToBase64String({0})", "byte[]", typeof(byte[]), typeof(byte[]), "{0}", "GetValue") },
 | 
			
		||||
//				{ (int)OracleDbType.Timestamp, ("(byte[])", "Convert.FromBase64String({0})", "Convert.ToBase64String({0})", "byte[]", typeof(byte[]), typeof(byte[]), "{0}", "GetValue") },
 | 
			
		||||
 | 
			
		||||
//				{ (int)OracleDbType.Char, ("", "{0}.Replace(StringifySplit, \"|\")", "{0}.Replace(\"|\", StringifySplit)", "string", typeof(string), typeof(string), "{0}", "GetString") },
 | 
			
		||||
//				{ (int)OracleDbType.VarChar, ("", "{0}.Replace(StringifySplit, \"|\")", "{0}.Replace(\"|\", StringifySplit)", "string", typeof(string), typeof(string), "{0}", "GetString") },
 | 
			
		||||
//				{ (int)OracleDbType.Text, ("", "{0}.Replace(StringifySplit, \"|\")", "{0}.Replace(\"|\", StringifySplit)", "string", typeof(string), typeof(string), "{0}", "GetString") },
 | 
			
		||||
//				{ (int)OracleDbType.NChar, ("", "{0}.Replace(StringifySplit, \"|\")", "{0}.Replace(\"|\", StringifySplit)", "string", typeof(string), typeof(string), "{0}", "GetString") },
 | 
			
		||||
//				{ (int)OracleDbType.NVarChar, ("", "{0}.Replace(StringifySplit, \"|\")", "{0}.Replace(\"|\", StringifySplit)", "string", typeof(string), typeof(string), "{0}", "GetString") },
 | 
			
		||||
//				{ (int)OracleDbType.NText, ("", "{0}.Replace(StringifySplit, \"|\")", "{0}.Replace(\"|\", StringifySplit)", "string", typeof(string), typeof(string), "{0}", "GetString") },
 | 
			
		||||
 | 
			
		||||
//				{ (int)OracleDbType.UniqueIdentifier, ("(Guid?)", "Guid.Parse({0})", "{0}.ToString()", "Guid?", typeof(Guid), typeof(Guid?), "{0}.Value", "GetGuid") },
 | 
			
		||||
//			};
 | 
			
		||||
 | 
			
		||||
//		public string GetCsConvert(DbColumnInfo column) => _dicDbToCs.TryGetValue(column.DbType, out var trydc) ? (column.IsNullable ? trydc.csConvert : trydc.csConvert.Replace("?", "")) : null;
 | 
			
		||||
//		public string GetCsParse(DbColumnInfo column) => _dicDbToCs.TryGetValue(column.DbType, out var trydc) ? trydc.csParse : null;
 | 
			
		||||
//		public string GetCsStringify(DbColumnInfo column) => _dicDbToCs.TryGetValue(column.DbType, out var trydc) ? trydc.csStringify : null;
 | 
			
		||||
//		public string GetCsType(DbColumnInfo column) => _dicDbToCs.TryGetValue(column.DbType, out var trydc) ? (column.IsNullable ? trydc.csType : trydc.csType.Replace("?", "")) : null;
 | 
			
		||||
//		public Type GetCsTypeInfo(DbColumnInfo column) => _dicDbToCs.TryGetValue(column.DbType, out var trydc) ? trydc.csTypeInfo : null;
 | 
			
		||||
//		public string GetCsTypeValue(DbColumnInfo column) => _dicDbToCs.TryGetValue(column.DbType, out var trydc) ? trydc.csTypeValue : null;
 | 
			
		||||
//		public string GetDataReaderMethod(DbColumnInfo column) => _dicDbToCs.TryGetValue(column.DbType, out var trydc) ? trydc.dataReaderMethod : null;
 | 
			
		||||
 | 
			
		||||
//		public List<string> GetDatabases() {
 | 
			
		||||
//			var sql = @" select username from all_users";
 | 
			
		||||
//			var ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
 | 
			
		||||
//			return ds.Select(a => a.FirstOrDefault()?.ToString()).ToList();
 | 
			
		||||
//		}
 | 
			
		||||
 | 
			
		||||
//		public List<DbTableInfo> GetTablesByDatabase(params string[] database2) {
 | 
			
		||||
//			var loc1 = new List<DbTableInfo>();
 | 
			
		||||
//			var loc2 = new Dictionary<string, DbTableInfo>();
 | 
			
		||||
//			var loc3 = new Dictionary<string, Dictionary<string, DbColumnInfo>>();
 | 
			
		||||
//			var database = database2?.ToArray();
 | 
			
		||||
 | 
			
		||||
//			if (database == null || database.Any() == false) {
 | 
			
		||||
//				using (var conn = _orm.Ado.MasterPool.Get()) {
 | 
			
		||||
//					if (string.IsNullOrEmpty(conn.Value.Database)) return loc1;
 | 
			
		||||
//					database = new[] { conn.Value.Database };
 | 
			
		||||
//				}
 | 
			
		||||
//			}
 | 
			
		||||
//			var databaseIn = string.Join(",", database.Select(a => "{0}".FormatOracleSQL(a)));
 | 
			
		||||
//			var sql = string.Format(@"
 | 
			
		||||
//select
 | 
			
		||||
//'TABLE:' || a.owner || '.' || a.table_name,
 | 
			
		||||
//a.owner,
 | 
			
		||||
//a.table_name,
 | 
			
		||||
//b.comments,
 | 
			
		||||
//'TABLE'
 | 
			
		||||
//from all_tables a
 | 
			
		||||
//left join all_tab_comments b on b.owner = a.owner and b.table_name = a.table_name and b.table_type = 'TABLE'
 | 
			
		||||
//where a.owner in ({0})", databaseIn);
 | 
			
		||||
//			var ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
 | 
			
		||||
//			if (ds == null) return loc1;
 | 
			
		||||
 | 
			
		||||
//			var loc6 = new List<string>();
 | 
			
		||||
//			var loc66 = new List<string>();
 | 
			
		||||
//			foreach (var row in ds) {
 | 
			
		||||
//				var table_id = string.Concat(row[0]);
 | 
			
		||||
//				var schema = string.Concat(row[1]);
 | 
			
		||||
//				var table = string.Concat(row[2]);
 | 
			
		||||
//				var comment = string.Concat(row[3]);
 | 
			
		||||
//				var type = string.Concat(row[4]) == "VIEW" ? DbTableType.VIEW : DbTableType.TABLE;
 | 
			
		||||
//				if (database.Length == 1) {
 | 
			
		||||
//					table_id = table_id.Substring(table_id.IndexOf('.') + 1);
 | 
			
		||||
//					schema = "";
 | 
			
		||||
//				}
 | 
			
		||||
//				loc2.Add(table_id, new DbTableInfo { Id = table_id, Schema = schema, Name = table, Comment = comment, Type = type });
 | 
			
		||||
//				loc3.Add(table_id, new Dictionary<string, DbColumnInfo>());
 | 
			
		||||
//				switch (type) {
 | 
			
		||||
//					case DbTableType.TABLE:
 | 
			
		||||
//					case DbTableType.VIEW:
 | 
			
		||||
//						loc6.Add(table.Replace("'", "''"));
 | 
			
		||||
//						break;
 | 
			
		||||
//					case DbTableType.StoreProcedure:
 | 
			
		||||
//						loc66.Add(table.Replace("'", "''"));
 | 
			
		||||
//						break;
 | 
			
		||||
//				}
 | 
			
		||||
//			}
 | 
			
		||||
//			if (loc6.Count == 0) return loc1;
 | 
			
		||||
//			var loc8 = "'" + string.Join("','", loc6.ToArray()) + "'";
 | 
			
		||||
//			var loc88 = "'" + string.Join("','", loc66.ToArray()) + "'";
 | 
			
		||||
 | 
			
		||||
//			sql = string.Format(@"
 | 
			
		||||
//select
 | 
			
		||||
//concat(a.table_schema, '.', a.table_name),
 | 
			
		||||
//a.column_name,
 | 
			
		||||
//a.data_type,
 | 
			
		||||
//ifnull(a.character_maximum_length, 0) 'len',
 | 
			
		||||
//a.column_type,
 | 
			
		||||
//case when a.is_nullable = 'YES' then 1 else 0 end 'is_nullable',
 | 
			
		||||
//case when locate('auto_increment', a.extra) > 0 then 1 else 0 end 'is_identity',
 | 
			
		||||
//a.column_comment 'comment'
 | 
			
		||||
//from information_schema.columns a
 | 
			
		||||
//where a.table_schema in ({1}) and a.table_name in ({0})
 | 
			
		||||
//", loc8, databaseIn);
 | 
			
		||||
//			ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
 | 
			
		||||
//			if (ds == null) return loc1;
 | 
			
		||||
 | 
			
		||||
//			foreach (var row in ds) {
 | 
			
		||||
//				string table_id = string.Concat(row[0]);
 | 
			
		||||
//				string column = string.Concat(row[1]);
 | 
			
		||||
//				string type = string.Concat(row[2]);
 | 
			
		||||
//				//long max_length = long.Parse(string.Concat(row[3]));
 | 
			
		||||
//				string sqlType = string.Concat(row[4]);
 | 
			
		||||
//				var m_len = Regex.Match(sqlType, @"\w+\((\d+)");
 | 
			
		||||
//				int max_length = m_len.Success ? int.Parse(m_len.Groups[1].Value) : -1;
 | 
			
		||||
//				bool is_nullable = string.Concat(row[5]) == "1";
 | 
			
		||||
//				bool is_identity = string.Concat(row[6]) == "1";
 | 
			
		||||
//				string comment = string.Concat(row[7]);
 | 
			
		||||
//				if (max_length == 0) max_length = -1;
 | 
			
		||||
//				if (database.Length == 1) {
 | 
			
		||||
//					table_id = table_id.Substring(table_id.IndexOf('.') + 1);
 | 
			
		||||
//				}
 | 
			
		||||
//				loc3[table_id].Add(column, new DbColumnInfo {
 | 
			
		||||
//					Name = column,
 | 
			
		||||
//					MaxLength = max_length,
 | 
			
		||||
//					IsIdentity = is_identity,
 | 
			
		||||
//					IsNullable = is_nullable,
 | 
			
		||||
//					IsPrimary = false,
 | 
			
		||||
//					DbTypeText = type,
 | 
			
		||||
//					DbTypeTextFull = sqlType,
 | 
			
		||||
//					Table = loc2[table_id],
 | 
			
		||||
//					Coment = comment
 | 
			
		||||
//				});
 | 
			
		||||
//				loc3[table_id][column].DbType = this.GetDbType(loc3[table_id][column]);
 | 
			
		||||
//				loc3[table_id][column].CsType = this.GetCsTypeInfo(loc3[table_id][column]);
 | 
			
		||||
//			}
 | 
			
		||||
 | 
			
		||||
//			sql = string.Format(@"
 | 
			
		||||
//select 
 | 
			
		||||
//concat(a.constraint_schema, '.', a.table_name) 'table_id',
 | 
			
		||||
//a.column_name,
 | 
			
		||||
//concat(a.constraint_schema, '/', a.table_name, '/', a.constraint_name) 'index_id',
 | 
			
		||||
//1 'IsUnique',
 | 
			
		||||
//case when constraint_name = 'PRIMARY' then 1 else 0 end 'IsPrimaryKey',
 | 
			
		||||
//0 'IsClustered',
 | 
			
		||||
//0 'IsDesc'
 | 
			
		||||
//from information_schema.key_column_usage a
 | 
			
		||||
//where a.constraint_schema in ({1}) and a.table_name in ({0}) and isnull(position_in_unique_constraint)
 | 
			
		||||
//", loc8, databaseIn);
 | 
			
		||||
//			ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
 | 
			
		||||
//			if (ds == null) return loc1;
 | 
			
		||||
 | 
			
		||||
//			var indexColumns = new Dictionary<string, Dictionary<string, List<DbColumnInfo>>>();
 | 
			
		||||
//			var uniqueColumns = new Dictionary<string, Dictionary<string, List<DbColumnInfo>>>();
 | 
			
		||||
//			foreach (var row in ds) {
 | 
			
		||||
//				string table_id = string.Concat(row[0]);
 | 
			
		||||
//				string column = string.Concat(row[1]);
 | 
			
		||||
//				string index_id = string.Concat(row[2]);
 | 
			
		||||
//				bool is_unique = string.Concat(row[3]) == "1";
 | 
			
		||||
//				bool is_primary_key = string.Concat(row[4]) == "1";
 | 
			
		||||
//				bool is_clustered = string.Concat(row[5]) == "1";
 | 
			
		||||
//				int is_desc = int.Parse(string.Concat(row[6]));
 | 
			
		||||
//				if (database.Length == 1) {
 | 
			
		||||
//					table_id = table_id.Substring(table_id.IndexOf('.') + 1);
 | 
			
		||||
//				}
 | 
			
		||||
//				if (loc3.ContainsKey(table_id) == false || loc3[table_id].ContainsKey(column) == false) continue;
 | 
			
		||||
//				var loc9 = loc3[table_id][column];
 | 
			
		||||
//				if (loc9.IsPrimary == false && is_primary_key) loc9.IsPrimary = is_primary_key;
 | 
			
		||||
 | 
			
		||||
//				Dictionary<string, List<DbColumnInfo>> loc10 = null;
 | 
			
		||||
//				List<DbColumnInfo> loc11 = null;
 | 
			
		||||
//				if (!indexColumns.TryGetValue(table_id, out loc10))
 | 
			
		||||
//					indexColumns.Add(table_id, loc10 = new Dictionary<string, List<DbColumnInfo>>());
 | 
			
		||||
//				if (!loc10.TryGetValue(index_id, out loc11))
 | 
			
		||||
//					loc10.Add(index_id, loc11 = new List<DbColumnInfo>());
 | 
			
		||||
//				loc11.Add(loc9);
 | 
			
		||||
//				if (is_unique) {
 | 
			
		||||
//					if (!uniqueColumns.TryGetValue(table_id, out loc10))
 | 
			
		||||
//						uniqueColumns.Add(table_id, loc10 = new Dictionary<string, List<DbColumnInfo>>());
 | 
			
		||||
//					if (!loc10.TryGetValue(index_id, out loc11))
 | 
			
		||||
//						loc10.Add(index_id, loc11 = new List<DbColumnInfo>());
 | 
			
		||||
//					loc11.Add(loc9);
 | 
			
		||||
//				}
 | 
			
		||||
//			}
 | 
			
		||||
//			foreach (string table_id in indexColumns.Keys) {
 | 
			
		||||
//				foreach (var columns in indexColumns[table_id].Values)
 | 
			
		||||
//					loc2[table_id].Indexes.Add(columns);
 | 
			
		||||
//			}
 | 
			
		||||
//			foreach (string table_id in uniqueColumns.Keys) {
 | 
			
		||||
//				foreach (var columns in uniqueColumns[table_id].Values) {
 | 
			
		||||
//					columns.Sort((c1, c2) => c1.Name.CompareTo(c2.Name));
 | 
			
		||||
//					loc2[table_id].Uniques.Add(columns);
 | 
			
		||||
//				}
 | 
			
		||||
//			}
 | 
			
		||||
 | 
			
		||||
//			sql = string.Format(@"
 | 
			
		||||
//select 
 | 
			
		||||
//concat(a.constraint_schema, '.', a.table_name) 'table_id',
 | 
			
		||||
//a.column_name,
 | 
			
		||||
//concat(a.constraint_schema, '/', a.constraint_name) 'FKId',
 | 
			
		||||
//concat(a.referenced_table_schema, '.', a.referenced_table_name) 'ref_table_id',
 | 
			
		||||
//1 'IsForeignKey',
 | 
			
		||||
//a.referenced_column_name 'ref_column'
 | 
			
		||||
//from information_schema.key_column_usage a
 | 
			
		||||
//where a.constraint_schema in ({1}) and a.table_name in ({0}) and not isnull(position_in_unique_constraint)
 | 
			
		||||
//", loc8, databaseIn);
 | 
			
		||||
//			ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
 | 
			
		||||
//			if (ds == null) return loc1;
 | 
			
		||||
 | 
			
		||||
//			var fkColumns = new Dictionary<string, Dictionary<string, DbForeignInfo>>();
 | 
			
		||||
//			foreach (var row in ds) {
 | 
			
		||||
//				string table_id = string.Concat(row[0]);
 | 
			
		||||
//				string column = string.Concat(row[1]);
 | 
			
		||||
//				string fk_id = string.Concat(row[2]);
 | 
			
		||||
//				string ref_table_id = string.Concat(row[3]);
 | 
			
		||||
//				bool is_foreign_key = string.Concat(row[4]) == "1";
 | 
			
		||||
//				string referenced_column = string.Concat(row[5]);
 | 
			
		||||
//				if (database.Length == 1) {
 | 
			
		||||
//					table_id = table_id.Substring(table_id.IndexOf('.') + 1);
 | 
			
		||||
//					ref_table_id = ref_table_id.Substring(ref_table_id.IndexOf('.') + 1);
 | 
			
		||||
//				}
 | 
			
		||||
//				if (loc3.ContainsKey(table_id) == false || loc3[table_id].ContainsKey(column) == false) continue;
 | 
			
		||||
//				var loc9 = loc3[table_id][column];
 | 
			
		||||
//				if (loc2.ContainsKey(ref_table_id) == false) continue;
 | 
			
		||||
//				var loc10 = loc2[ref_table_id];
 | 
			
		||||
//				var loc11 = loc3[ref_table_id][referenced_column];
 | 
			
		||||
 | 
			
		||||
//				Dictionary<string, DbForeignInfo> loc12 = null;
 | 
			
		||||
//				DbForeignInfo loc13 = null;
 | 
			
		||||
//				if (!fkColumns.TryGetValue(table_id, out loc12))
 | 
			
		||||
//					fkColumns.Add(table_id, loc12 = new Dictionary<string, DbForeignInfo>());
 | 
			
		||||
//				if (!loc12.TryGetValue(fk_id, out loc13))
 | 
			
		||||
//					loc12.Add(fk_id, loc13 = new DbForeignInfo { Table = loc2[table_id], ReferencedTable = loc10 });
 | 
			
		||||
//				loc13.Columns.Add(loc9);
 | 
			
		||||
//				loc13.ReferencedColumns.Add(loc11);
 | 
			
		||||
//			}
 | 
			
		||||
//			foreach (var table_id in fkColumns.Keys)
 | 
			
		||||
//				foreach (var fk in fkColumns[table_id].Values)
 | 
			
		||||
//					loc2[table_id].Foreigns.Add(fk);
 | 
			
		||||
 | 
			
		||||
//			foreach (var table_id in loc3.Keys) {
 | 
			
		||||
//				foreach (var loc5 in loc3[table_id].Values) {
 | 
			
		||||
//					loc2[table_id].Columns.Add(loc5);
 | 
			
		||||
//					if (loc5.IsIdentity) loc2[table_id].Identitys.Add(loc5);
 | 
			
		||||
//					if (loc5.IsPrimary) loc2[table_id].Primarys.Add(loc5);
 | 
			
		||||
//				}
 | 
			
		||||
//			}
 | 
			
		||||
//			foreach (var loc4 in loc2.Values) {
 | 
			
		||||
//				if (loc4.Primarys.Count == 0 && loc4.Uniques.Count > 0) {
 | 
			
		||||
//					foreach (var loc5 in loc4.Uniques[0]) {
 | 
			
		||||
//						loc5.IsPrimary = true;
 | 
			
		||||
//						loc4.Primarys.Add(loc5);
 | 
			
		||||
//					}
 | 
			
		||||
//				}
 | 
			
		||||
//				loc4.Primarys.Sort((c1, c2) => c1.Name.CompareTo(c2.Name));
 | 
			
		||||
//				loc4.Columns.Sort((c1, c2) => {
 | 
			
		||||
//					int compare = c2.IsPrimary.CompareTo(c1.IsPrimary);
 | 
			
		||||
//					if (compare == 0) {
 | 
			
		||||
//						bool b1 = loc4.Foreigns.Find(fk => fk.Columns.Find(c3 => c3.Name == c1.Name) != null) != null;
 | 
			
		||||
//						bool b2 = loc4.Foreigns.Find(fk => fk.Columns.Find(c3 => c3.Name == c2.Name) != null) != null;
 | 
			
		||||
//						compare = b2.CompareTo(b1);
 | 
			
		||||
//					}
 | 
			
		||||
//					if (compare == 0) compare = c1.Name.CompareTo(c2.Name);
 | 
			
		||||
//					return compare;
 | 
			
		||||
//				});
 | 
			
		||||
//				loc1.Add(loc4);
 | 
			
		||||
//			}
 | 
			
		||||
//			loc1.Sort((t1, t2) => {
 | 
			
		||||
//				var ret = t1.Schema.CompareTo(t2.Schema);
 | 
			
		||||
//				if (ret == 0) ret = t1.Name.CompareTo(t2.Name);
 | 
			
		||||
//				return ret;
 | 
			
		||||
//			});
 | 
			
		||||
//			foreach (var loc4 in loc1) {
 | 
			
		||||
//				var dicUniques = new Dictionary<string, List<DbColumnInfo>>();
 | 
			
		||||
//				if (loc4.Primarys.Count > 0) dicUniques.Add(string.Join(",", loc4.Primarys.Select(a => a.Name)), loc4.Primarys);
 | 
			
		||||
//				foreach (var loc5 in loc4.Uniques) {
 | 
			
		||||
//					var dickey = string.Join(",", loc5.Select(a => a.Name));
 | 
			
		||||
//					if (dicUniques.ContainsKey(dickey)) continue;
 | 
			
		||||
//					dicUniques.Add(dickey, loc5);
 | 
			
		||||
//				}
 | 
			
		||||
//				loc4.Uniques = dicUniques.Values.ToList();
 | 
			
		||||
//			}
 | 
			
		||||
 | 
			
		||||
//			loc2.Clear();
 | 
			
		||||
//			loc3.Clear();
 | 
			
		||||
//			return loc1;
 | 
			
		||||
//		}
 | 
			
		||||
 | 
			
		||||
//		public List<DbEnumInfo> GetEnumsByDatabase(params string[] database) {
 | 
			
		||||
//			return new List<DbEnumInfo>();
 | 
			
		||||
//		}
 | 
			
		||||
//	}
 | 
			
		||||
//}
 | 
			
		||||
@@ -27,7 +27,7 @@ namespace FreeSql.Oracle {
 | 
			
		||||
		public IAop Aop { get; }
 | 
			
		||||
		public ICache Cache { get; }
 | 
			
		||||
		public ICodeFirst CodeFirst { get; }
 | 
			
		||||
		public IDbFirst DbFirst => null;
 | 
			
		||||
		public IDbFirst DbFirst { get; }
 | 
			
		||||
		public OracleProvider(IDistributedCache cache, ILogger log, string masterConnectionString, string[] slaveConnectionString) {
 | 
			
		||||
			if (log == null) log = new LoggerFactory(new[] { new Microsoft.Extensions.Logging.Debug.DebugLoggerProvider() }).CreateLogger("FreeSql.Oracle");
 | 
			
		||||
 | 
			
		||||
@@ -38,6 +38,7 @@ namespace FreeSql.Oracle {
 | 
			
		||||
			this.Ado = new OracleAdo(this.InternalCommonUtils, this.Cache, log, masterConnectionString, slaveConnectionString);
 | 
			
		||||
			this.Aop = new AopProvider();
 | 
			
		||||
 | 
			
		||||
			//this.DbFirst = new OracleDbFirst(this, this.InternalCommonUtils, this.InternalCommonExpression);
 | 
			
		||||
			this.CodeFirst = new OracleCodeFirst(this, this.InternalCommonUtils, this.InternalCommonExpression);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -10,13 +10,15 @@ namespace FreeSql.PostgreSQL.Curd {
 | 
			
		||||
 | 
			
		||||
	class PostgreSQLSelect<T1> : FreeSql.Internal.CommonProvider.Select1Provider<T1> where T1 : class {
 | 
			
		||||
 | 
			
		||||
		internal static string ToSqlStatic(CommonUtils _commonUtils, string _select, string field, StringBuilder _join, StringBuilder _where, string _groupby, string _having, string _orderby, int _skip, int _limit, List<SelectTableInfo> _tables, Func<Type, string, string> tableRuleInvoke, IFreeSql _orm) {
 | 
			
		||||
		internal static string ToSqlStatic(CommonUtils _commonUtils, string _select, bool _distinct, string field, StringBuilder _join, StringBuilder _where, string _groupby, string _having, string _orderby, int _skip, int _limit, List<SelectTableInfo> _tables, Func<Type, string, string> tableRuleInvoke, IFreeSql _orm) {
 | 
			
		||||
			if (_orm.CodeFirst.IsAutoSyncStructure)
 | 
			
		||||
				_orm.CodeFirst.SyncStructure(_tables.Select(a => a.Table.Type).ToArray());
 | 
			
		||||
 | 
			
		||||
			var sb = new StringBuilder();
 | 
			
		||||
			var sbnav = new StringBuilder();
 | 
			
		||||
			sb.Append(_select).Append(field).Append(" \r\nFROM ");
 | 
			
		||||
			sb.Append(_select);
 | 
			
		||||
			if (_distinct) sb.Append("DISTINCT ");
 | 
			
		||||
			sb.Append(field).Append(" \r\nFROM ");
 | 
			
		||||
			var tbsjoin = _tables.Where(a => a.Type != SelectTableInfoType.From).ToArray();
 | 
			
		||||
			var tbsfrom = _tables.Where(a => a.Type == SelectTableInfoType.From).ToArray();
 | 
			
		||||
			for (var a = 0; a < tbsfrom.Length; a++) {
 | 
			
		||||
@@ -86,42 +88,42 @@ namespace FreeSql.PostgreSQL.Curd {
 | 
			
		||||
		public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8> From<T2, T3, T4, T5, T6, T7, T8>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp?.Body); var ret = new PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8>(_orm, _commonUtils, _commonExpression, null); PostgreSQLSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
 | 
			
		||||
		public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> From<T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp?.Body); var ret = new PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>(_orm, _commonUtils, _commonExpression, null); PostgreSQLSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
 | 
			
		||||
		public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> From<T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp?.Body); var ret = new PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(_orm, _commonUtils, _commonExpression, null); PostgreSQLSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
 | 
			
		||||
		public override string ToSql(string field = null) => ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	//class PostgreSQLSelect<T1, T2> : FreeSql.Internal.CommonProvider.Select2Provider<T1, T2> where T1 : class where T2 : class {
 | 
			
		||||
	//	public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
	//	public override string ToSql(string field = null) => PostgreSQLSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllField().field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRulesInvoke, _orm);
 | 
			
		||||
	//	public override string ToSql(string field = null) => PostgreSQLSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllField().field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRulesInvoke, _orm);
 | 
			
		||||
	//}
 | 
			
		||||
	class PostgreSQLSelect<T1, T2, T3> : FreeSql.Internal.CommonProvider.Select3Provider<T1, T2, T3> where T1 : class where T2 : class where T3 : class {
 | 
			
		||||
		public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => PostgreSQLSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => PostgreSQLSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class PostgreSQLSelect<T1, T2, T3, T4> : FreeSql.Internal.CommonProvider.Select4Provider<T1, T2, T3, T4> where T1 : class where T2 : class where T3 : class where T4 : class {
 | 
			
		||||
		public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => PostgreSQLSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => PostgreSQLSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class PostgreSQLSelect<T1, T2, T3, T4, T5> : FreeSql.Internal.CommonProvider.Select5Provider<T1, T2, T3, T4, T5> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class {
 | 
			
		||||
		public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => PostgreSQLSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => PostgreSQLSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class PostgreSQLSelect<T1, T2, T3, T4, T5, T6> : FreeSql.Internal.CommonProvider.Select6Provider<T1, T2, T3, T4, T5, T6> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class {
 | 
			
		||||
		public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => PostgreSQLSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => PostgreSQLSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7> : FreeSql.Internal.CommonProvider.Select7Provider<T1, T2, T3, T4, T5, T6, T7> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class {
 | 
			
		||||
		public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => PostgreSQLSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => PostgreSQLSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8> : FreeSql.Internal.CommonProvider.Select8Provider<T1, T2, T3, T4, T5, T6, T7, T8> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class {
 | 
			
		||||
		public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => PostgreSQLSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => PostgreSQLSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> : FreeSql.Internal.CommonProvider.Select9Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class {
 | 
			
		||||
		public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => PostgreSQLSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => PostgreSQLSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> : FreeSql.Internal.CommonProvider.Select10Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> where T1 : class 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 {
 | 
			
		||||
		public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => PostgreSQLSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => PostgreSQLSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -10,19 +10,20 @@ namespace FreeSql.SqlServer.Curd {
 | 
			
		||||
 | 
			
		||||
	class SqlServerSelect<T1> : FreeSql.Internal.CommonProvider.Select1Provider<T1> where T1 : class {
 | 
			
		||||
 | 
			
		||||
		internal static string ToSqlStatic(CommonUtils _commonUtils, string _select, string field, StringBuilder _join, StringBuilder _where, string _groupby, string _having, string _orderby, int _skip, int _limit, List<SelectTableInfo> _tables, Func<Type, string, string> tableRuleInvoke, IFreeSql _orm)
 | 
			
		||||
		internal static string ToSqlStatic(CommonUtils _commonUtils, string _select, bool _distinct, string field, StringBuilder _join, StringBuilder _where, string _groupby, string _having, string _orderby, int _skip, int _limit, List<SelectTableInfo> _tables, Func<Type, string, string> tableRuleInvoke, IFreeSql _orm)
 | 
			
		||||
			=> (_commonUtils as SqlServerUtils).IsSelectRowNumber ?
 | 
			
		||||
			ToSqlStaticRowNumber(_commonUtils, _select, field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, tableRuleInvoke, _orm) :
 | 
			
		||||
			ToSqlStaticOffsetFetchNext(_commonUtils, _select, field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, tableRuleInvoke, _orm);
 | 
			
		||||
			ToSqlStaticRowNumber(_commonUtils, _select, _distinct, field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, tableRuleInvoke, _orm) :
 | 
			
		||||
			ToSqlStaticOffsetFetchNext(_commonUtils, _select, _distinct, field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, tableRuleInvoke, _orm);
 | 
			
		||||
 | 
			
		||||
		#region SqlServer 2005 row_number
 | 
			
		||||
		internal static string ToSqlStaticRowNumber(CommonUtils _commonUtils, string _select, string field, StringBuilder _join, StringBuilder _where, string _groupby, string _having, string _orderby, int _skip, int _limit, List<SelectTableInfo> _tables, Func<Type, string, string> tableRuleInvoke, IFreeSql _orm) {
 | 
			
		||||
		internal static string ToSqlStaticRowNumber(CommonUtils _commonUtils, string _select, bool _distinct, string field, StringBuilder _join, StringBuilder _where, string _groupby, string _having, string _orderby, int _skip, int _limit, List<SelectTableInfo> _tables, Func<Type, string, string> tableRuleInvoke, IFreeSql _orm) {
 | 
			
		||||
			if (_orm.CodeFirst.IsAutoSyncStructure)
 | 
			
		||||
				_orm.CodeFirst.SyncStructure(_tables.Select(a => a.Table.Type).ToArray());
 | 
			
		||||
 | 
			
		||||
			var sb = new StringBuilder();
 | 
			
		||||
			var sbnav = new StringBuilder();
 | 
			
		||||
			sb.Append(_select);
 | 
			
		||||
			if (_distinct) sb.Append("DISTINCT ");
 | 
			
		||||
			if (_limit > 0) sb.Append("TOP ").Append(_skip + _limit).Append(" ");
 | 
			
		||||
			sb.Append(field);
 | 
			
		||||
			if (_skip > 0) {
 | 
			
		||||
@@ -95,13 +96,14 @@ namespace FreeSql.SqlServer.Curd {
 | 
			
		||||
		#endregion
 | 
			
		||||
 | 
			
		||||
		#region SqlServer 2012+ offset feach next
 | 
			
		||||
		internal static string ToSqlStaticOffsetFetchNext(CommonUtils _commonUtils, string _select, string field, StringBuilder _join, StringBuilder _where, string _groupby, string _having, string _orderby, int _skip, int _limit, List<SelectTableInfo> _tables, Func<Type, string, string> tableRuleInvoke, IFreeSql _orm) {
 | 
			
		||||
		internal static string ToSqlStaticOffsetFetchNext(CommonUtils _commonUtils, string _select, bool _distinct, string field, StringBuilder _join, StringBuilder _where, string _groupby, string _having, string _orderby, int _skip, int _limit, List<SelectTableInfo> _tables, Func<Type, string, string> tableRuleInvoke, IFreeSql _orm) {
 | 
			
		||||
			if (_orm.CodeFirst.IsAutoSyncStructure)
 | 
			
		||||
				_orm.CodeFirst.SyncStructure(_tables.Select(a => a.Table.Type).ToArray());
 | 
			
		||||
 | 
			
		||||
			var sb = new StringBuilder();
 | 
			
		||||
			var sbnav = new StringBuilder();
 | 
			
		||||
			sb.Append(_select);
 | 
			
		||||
			if (_distinct) sb.Append("DISTINCT ");
 | 
			
		||||
			if (_skip <= 0 && _limit > 0) sb.Append("TOP ").Append(_limit).Append(" ");
 | 
			
		||||
			sb.Append(field);
 | 
			
		||||
			sb.Append(" \r\nFROM ");
 | 
			
		||||
@@ -181,42 +183,42 @@ namespace FreeSql.SqlServer.Curd {
 | 
			
		||||
		public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8> From<T2, T3, T4, T5, T6, T7, T8>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp?.Body); var ret = new SqlServerSelect<T1, T2, T3, T4, T5, T6, T7, T8>(_orm, _commonUtils, _commonExpression, null); SqlServerSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
 | 
			
		||||
		public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> From<T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp?.Body); var ret = new SqlServerSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>(_orm, _commonUtils, _commonExpression, null); SqlServerSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
 | 
			
		||||
		public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> From<T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp?.Body); var ret = new SqlServerSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(_orm, _commonUtils, _commonExpression, null); SqlServerSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
 | 
			
		||||
		public override string ToSql(string field = null) => ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	//class SqlServerSelect<T1, T2> : FreeSql.Internal.CommonProvider.Select2Provider<T1, T2> where T1 : class where T2 : class {
 | 
			
		||||
	//	public SqlServerSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
	//	public override string ToSql(string field = null) => SqlServerSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllField().field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRulesInvoke, _orm);
 | 
			
		||||
	//	public override string ToSql(string field = null) => SqlServerSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllField().field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRulesInvoke, _orm);
 | 
			
		||||
	//}
 | 
			
		||||
	class SqlServerSelect<T1, T2, T3> : FreeSql.Internal.CommonProvider.Select3Provider<T1, T2, T3> where T1 : class where T2 : class where T3 : class {
 | 
			
		||||
		public SqlServerSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => SqlServerSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => SqlServerSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class SqlServerSelect<T1, T2, T3, T4> : FreeSql.Internal.CommonProvider.Select4Provider<T1, T2, T3, T4> where T1 : class where T2 : class where T3 : class where T4 : class {
 | 
			
		||||
		public SqlServerSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => SqlServerSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => SqlServerSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class SqlServerSelect<T1, T2, T3, T4, T5> : FreeSql.Internal.CommonProvider.Select5Provider<T1, T2, T3, T4, T5> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class {
 | 
			
		||||
		public SqlServerSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => SqlServerSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => SqlServerSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class SqlServerSelect<T1, T2, T3, T4, T5, T6> : FreeSql.Internal.CommonProvider.Select6Provider<T1, T2, T3, T4, T5, T6> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class {
 | 
			
		||||
		public SqlServerSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => SqlServerSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => SqlServerSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class SqlServerSelect<T1, T2, T3, T4, T5, T6, T7> : FreeSql.Internal.CommonProvider.Select7Provider<T1, T2, T3, T4, T5, T6, T7> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class {
 | 
			
		||||
		public SqlServerSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => SqlServerSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => SqlServerSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class SqlServerSelect<T1, T2, T3, T4, T5, T6, T7, T8> : FreeSql.Internal.CommonProvider.Select8Provider<T1, T2, T3, T4, T5, T6, T7, T8> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class {
 | 
			
		||||
		public SqlServerSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => SqlServerSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => SqlServerSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class SqlServerSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> : FreeSql.Internal.CommonProvider.Select9Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class {
 | 
			
		||||
		public SqlServerSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => SqlServerSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => SqlServerSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class SqlServerSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> : FreeSql.Internal.CommonProvider.Select10Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> where T1 : class 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 {
 | 
			
		||||
		public SqlServerSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => SqlServerSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => SqlServerSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -10,13 +10,15 @@ namespace FreeSql.Sqlite.Curd {
 | 
			
		||||
 | 
			
		||||
	class SqliteSelect<T1> : FreeSql.Internal.CommonProvider.Select1Provider<T1> where T1 : class {
 | 
			
		||||
 | 
			
		||||
		internal static string ToSqlStatic(CommonUtils _commonUtils, string _select, string field, StringBuilder _join, StringBuilder _where, string _groupby, string _having, string _orderby, int _skip, int _limit, List<SelectTableInfo> _tables, Func<Type, string, string> tableRuleInvoke, IFreeSql _orm) {
 | 
			
		||||
		internal static string ToSqlStatic(CommonUtils _commonUtils, string _select, bool _distinct, string field, StringBuilder _join, StringBuilder _where, string _groupby, string _having, string _orderby, int _skip, int _limit, List<SelectTableInfo> _tables, Func<Type, string, string> tableRuleInvoke, IFreeSql _orm) {
 | 
			
		||||
			if (_orm.CodeFirst.IsAutoSyncStructure)
 | 
			
		||||
				_orm.CodeFirst.SyncStructure(_tables.Select(a => a.Table.Type).ToArray());
 | 
			
		||||
 | 
			
		||||
			var sb = new StringBuilder();
 | 
			
		||||
			var sbnav = new StringBuilder();
 | 
			
		||||
			sb.Append(_select).Append(field).Append(" \r\nFROM ");
 | 
			
		||||
			sb.Append(_select);
 | 
			
		||||
			if (_distinct) sb.Append("DISTINCT ");
 | 
			
		||||
			sb.Append(field).Append(" \r\nFROM ");
 | 
			
		||||
			var tbsjoin = _tables.Where(a => a.Type != SelectTableInfoType.From).ToArray();
 | 
			
		||||
			var tbsfrom = _tables.Where(a => a.Type == SelectTableInfoType.From).ToArray();
 | 
			
		||||
			for (var a = 0; a < tbsfrom.Length; a++) {
 | 
			
		||||
@@ -84,38 +86,38 @@ namespace FreeSql.Sqlite.Curd {
 | 
			
		||||
		public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8> From<T2, T3, T4, T5, T6, T7, T8>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp?.Body); var ret = new SqliteSelect<T1, T2, T3, T4, T5, T6, T7, T8>(_orm, _commonUtils, _commonExpression, null); SqliteSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
 | 
			
		||||
		public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> From<T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp?.Body); var ret = new SqliteSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>(_orm, _commonUtils, _commonExpression, null); SqliteSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
 | 
			
		||||
		public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> From<T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp?.Body); var ret = new SqliteSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(_orm, _commonUtils, _commonExpression, null); SqliteSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
 | 
			
		||||
		public override string ToSql(string field = null) => ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class SqliteSelect<T1, T2, T3> : FreeSql.Internal.CommonProvider.Select3Provider<T1, T2, T3> where T1 : class where T2 : class where T3 : class {
 | 
			
		||||
		public SqliteSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => SqliteSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => SqliteSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class SqliteSelect<T1, T2, T3, T4> : FreeSql.Internal.CommonProvider.Select4Provider<T1, T2, T3, T4> where T1 : class where T2 : class where T3 : class where T4 : class {
 | 
			
		||||
		public SqliteSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => SqliteSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => SqliteSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class SqliteSelect<T1, T2, T3, T4, T5> : FreeSql.Internal.CommonProvider.Select5Provider<T1, T2, T3, T4, T5> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class {
 | 
			
		||||
		public SqliteSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => SqliteSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => SqliteSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class SqliteSelect<T1, T2, T3, T4, T5, T6> : FreeSql.Internal.CommonProvider.Select6Provider<T1, T2, T3, T4, T5, T6> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class {
 | 
			
		||||
		public SqliteSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => SqliteSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => SqliteSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class SqliteSelect<T1, T2, T3, T4, T5, T6, T7> : FreeSql.Internal.CommonProvider.Select7Provider<T1, T2, T3, T4, T5, T6, T7> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class {
 | 
			
		||||
		public SqliteSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => SqliteSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => SqliteSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class SqliteSelect<T1, T2, T3, T4, T5, T6, T7, T8> : FreeSql.Internal.CommonProvider.Select8Provider<T1, T2, T3, T4, T5, T6, T7, T8> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class {
 | 
			
		||||
		public SqliteSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => SqliteSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => SqliteSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class SqliteSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> : FreeSql.Internal.CommonProvider.Select9Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9> where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class {
 | 
			
		||||
		public SqliteSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => SqliteSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => SqliteSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
	class SqliteSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> : FreeSql.Internal.CommonProvider.Select10Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> where T1 : class 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 {
 | 
			
		||||
		public SqliteSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
 | 
			
		||||
		public override string ToSql(string field = null) => SqliteSelect<T1>.ToSqlStatic(_commonUtils, _select, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
		public override string ToSql(string field = null) => SqliteSelect<T1>.ToSqlStatic(_commonUtils, _select, _distinct, field ?? this.GetAllFieldExpressionTree().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, TableRuleInvoke, _orm);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user