mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 09:15:27 +08:00 
			
		
		
		
	源代码改用vs默认格式化
This commit is contained in:
		
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -6,126 +6,158 @@ using System.Diagnostics;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider {
 | 
			
		||||
	partial class AdoProvider {
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
{
 | 
			
		||||
    partial class AdoProvider
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
		class Transaction2 {
 | 
			
		||||
			internal Object<DbConnection> Conn;
 | 
			
		||||
			internal DbTransaction Transaction;
 | 
			
		||||
			internal DateTime RunTime;
 | 
			
		||||
			internal TimeSpan Timeout;
 | 
			
		||||
        class Transaction2
 | 
			
		||||
        {
 | 
			
		||||
            internal Object<DbConnection> Conn;
 | 
			
		||||
            internal DbTransaction Transaction;
 | 
			
		||||
            internal DateTime RunTime;
 | 
			
		||||
            internal TimeSpan Timeout;
 | 
			
		||||
 | 
			
		||||
			public Transaction2(Object<DbConnection> conn, DbTransaction tran, TimeSpan timeout) {
 | 
			
		||||
				Conn = conn;
 | 
			
		||||
				Transaction = tran;
 | 
			
		||||
				RunTime = DateTime.Now;
 | 
			
		||||
				Timeout = timeout;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
            public Transaction2(Object<DbConnection> conn, DbTransaction tran, TimeSpan timeout)
 | 
			
		||||
            {
 | 
			
		||||
                Conn = conn;
 | 
			
		||||
                Transaction = tran;
 | 
			
		||||
                RunTime = DateTime.Now;
 | 
			
		||||
                Timeout = timeout;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		private Dictionary<int, Transaction2> _trans = new Dictionary<int, Transaction2>();
 | 
			
		||||
		private object _trans_lock = new object();
 | 
			
		||||
        private Dictionary<int, Transaction2> _trans = new Dictionary<int, Transaction2>();
 | 
			
		||||
        private object _trans_lock = new object();
 | 
			
		||||
 | 
			
		||||
		public DbTransaction TransactionCurrentThread => _trans.TryGetValue(Thread.CurrentThread.ManagedThreadId, out var conn) && conn.Transaction?.Connection != null ? conn.Transaction : null;
 | 
			
		||||
        public DbTransaction TransactionCurrentThread => _trans.TryGetValue(Thread.CurrentThread.ManagedThreadId, out var conn) && conn.Transaction?.Connection != null ? conn.Transaction : null;
 | 
			
		||||
 | 
			
		||||
		public void BeginTransaction(TimeSpan timeout) {
 | 
			
		||||
			if (TransactionCurrentThread != null) return;
 | 
			
		||||
        public void BeginTransaction(TimeSpan timeout)
 | 
			
		||||
        {
 | 
			
		||||
            if (TransactionCurrentThread != null) return;
 | 
			
		||||
 | 
			
		||||
			int tid = Thread.CurrentThread.ManagedThreadId;
 | 
			
		||||
			Transaction2 tran = null;
 | 
			
		||||
			Object<DbConnection> conn = null;
 | 
			
		||||
            int tid = Thread.CurrentThread.ManagedThreadId;
 | 
			
		||||
            Transaction2 tran = null;
 | 
			
		||||
            Object<DbConnection> conn = null;
 | 
			
		||||
 | 
			
		||||
			try {
 | 
			
		||||
				conn = MasterPool.Get();
 | 
			
		||||
				tran = new Transaction2(conn, conn.Value.BeginTransaction(), timeout);
 | 
			
		||||
			} catch(Exception ex) {
 | 
			
		||||
				Trace.WriteLine($"数据库出错(开启事务){ex.Message} \r\n{ex.StackTrace}");
 | 
			
		||||
				MasterPool.Return(conn);
 | 
			
		||||
				throw ex;
 | 
			
		||||
			}
 | 
			
		||||
			if (_trans.ContainsKey(tid)) CommitTransaction();
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                conn = MasterPool.Get();
 | 
			
		||||
                tran = new Transaction2(conn, conn.Value.BeginTransaction(), timeout);
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
                Trace.WriteLine($"数据库出错(开启事务){ex.Message} \r\n{ex.StackTrace}");
 | 
			
		||||
                MasterPool.Return(conn);
 | 
			
		||||
                throw ex;
 | 
			
		||||
            }
 | 
			
		||||
            if (_trans.ContainsKey(tid)) CommitTransaction();
 | 
			
		||||
 | 
			
		||||
			lock (_trans_lock)
 | 
			
		||||
				_trans.Add(tid, tran);
 | 
			
		||||
		}
 | 
			
		||||
            lock (_trans_lock)
 | 
			
		||||
                _trans.Add(tid, tran);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		private void AutoCommitTransaction() {
 | 
			
		||||
			if (_trans.Count > 0) {
 | 
			
		||||
				Transaction2[] trans = null;
 | 
			
		||||
				lock (_trans_lock)
 | 
			
		||||
					trans = _trans.Values.Where(st2 => DateTime.Now.Subtract(st2.RunTime) > st2.Timeout).ToArray();
 | 
			
		||||
				foreach (Transaction2 tran in trans) CommitTransaction(true, tran);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		private void CommitTransaction(bool isCommit, Transaction2 tran) {
 | 
			
		||||
			if (tran == null || tran.Transaction == null || tran.Transaction.Connection == null) return;
 | 
			
		||||
        private void AutoCommitTransaction()
 | 
			
		||||
        {
 | 
			
		||||
            if (_trans.Count > 0)
 | 
			
		||||
            {
 | 
			
		||||
                Transaction2[] trans = null;
 | 
			
		||||
                lock (_trans_lock)
 | 
			
		||||
                    trans = _trans.Values.Where(st2 => DateTime.Now.Subtract(st2.RunTime) > st2.Timeout).ToArray();
 | 
			
		||||
                foreach (Transaction2 tran in trans) CommitTransaction(true, tran);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        private void CommitTransaction(bool isCommit, Transaction2 tran)
 | 
			
		||||
        {
 | 
			
		||||
            if (tran == null || tran.Transaction == null || tran.Transaction.Connection == null) return;
 | 
			
		||||
 | 
			
		||||
			if (_trans.ContainsKey(tran.Conn.LastGetThreadId))
 | 
			
		||||
				lock (_trans_lock)
 | 
			
		||||
					if (_trans.ContainsKey(tran.Conn.LastGetThreadId))
 | 
			
		||||
						_trans.Remove(tran.Conn.LastGetThreadId);
 | 
			
		||||
            if (_trans.ContainsKey(tran.Conn.LastGetThreadId))
 | 
			
		||||
                lock (_trans_lock)
 | 
			
		||||
                    if (_trans.ContainsKey(tran.Conn.LastGetThreadId))
 | 
			
		||||
                        _trans.Remove(tran.Conn.LastGetThreadId);
 | 
			
		||||
 | 
			
		||||
			Exception ex = null;
 | 
			
		||||
			var f001 = isCommit ? "提交" : "回滚";
 | 
			
		||||
			try {
 | 
			
		||||
				Trace.WriteLine($"线程{tran.Conn.LastGetThreadId}事务{f001}");
 | 
			
		||||
				if (isCommit) tran.Transaction.Commit();
 | 
			
		||||
				else tran.Transaction.Rollback();
 | 
			
		||||
			} catch (Exception ex2) {
 | 
			
		||||
				ex = ex2;
 | 
			
		||||
				Trace.WriteLine($"数据库出错({f001}事务):{ex.Message} {ex.StackTrace}");
 | 
			
		||||
			} finally {
 | 
			
		||||
				ReturnConnection(MasterPool, tran.Conn, ex); //MasterPool.Return(tran.Conn, ex);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		private void CommitTransaction(bool isCommit) {
 | 
			
		||||
			if (_trans.TryGetValue(Thread.CurrentThread.ManagedThreadId, out var tran)) CommitTransaction(isCommit, tran);
 | 
			
		||||
		}
 | 
			
		||||
		public void CommitTransaction() => CommitTransaction(true);
 | 
			
		||||
		public void RollbackTransaction() => CommitTransaction(false);
 | 
			
		||||
            Exception ex = null;
 | 
			
		||||
            var f001 = isCommit ? "提交" : "回滚";
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                Trace.WriteLine($"线程{tran.Conn.LastGetThreadId}事务{f001}");
 | 
			
		||||
                if (isCommit) tran.Transaction.Commit();
 | 
			
		||||
                else tran.Transaction.Rollback();
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex2)
 | 
			
		||||
            {
 | 
			
		||||
                ex = ex2;
 | 
			
		||||
                Trace.WriteLine($"数据库出错({f001}事务):{ex.Message} {ex.StackTrace}");
 | 
			
		||||
            }
 | 
			
		||||
            finally
 | 
			
		||||
            {
 | 
			
		||||
                ReturnConnection(MasterPool, tran.Conn, ex); //MasterPool.Return(tran.Conn, ex);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        private void CommitTransaction(bool isCommit)
 | 
			
		||||
        {
 | 
			
		||||
            if (_trans.TryGetValue(Thread.CurrentThread.ManagedThreadId, out var tran)) CommitTransaction(isCommit, tran);
 | 
			
		||||
        }
 | 
			
		||||
        public void CommitTransaction() => CommitTransaction(true);
 | 
			
		||||
        public void RollbackTransaction() => CommitTransaction(false);
 | 
			
		||||
 | 
			
		||||
		public void Transaction(Action handler) {
 | 
			
		||||
			Transaction(handler, TimeSpan.FromSeconds(60));
 | 
			
		||||
		}
 | 
			
		||||
		public void Transaction(Action handler, TimeSpan timeout) {
 | 
			
		||||
			try {
 | 
			
		||||
				BeginTransaction(timeout);
 | 
			
		||||
				handler();
 | 
			
		||||
				CommitTransaction();
 | 
			
		||||
			} catch (Exception ex) {
 | 
			
		||||
				RollbackTransaction();
 | 
			
		||||
				throw ex;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
        public void Transaction(Action handler)
 | 
			
		||||
        {
 | 
			
		||||
            Transaction(handler, TimeSpan.FromSeconds(60));
 | 
			
		||||
        }
 | 
			
		||||
        public void Transaction(Action handler, TimeSpan timeout)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                BeginTransaction(timeout);
 | 
			
		||||
                handler();
 | 
			
		||||
                CommitTransaction();
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
                RollbackTransaction();
 | 
			
		||||
                throw ex;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		~AdoProvider() {
 | 
			
		||||
			this.Dispose();
 | 
			
		||||
		}
 | 
			
		||||
		bool _isdisposed = false;
 | 
			
		||||
		public void Dispose() {
 | 
			
		||||
			if (_isdisposed) return;
 | 
			
		||||
			try {
 | 
			
		||||
				Transaction2[] trans = null;
 | 
			
		||||
				lock (_trans_lock)
 | 
			
		||||
					trans = _trans.Values.ToArray();
 | 
			
		||||
				foreach (Transaction2 tran in trans) CommitTransaction(false, tran);
 | 
			
		||||
			} catch { }
 | 
			
		||||
        ~AdoProvider()
 | 
			
		||||
        {
 | 
			
		||||
            this.Dispose();
 | 
			
		||||
        }
 | 
			
		||||
        bool _isdisposed = false;
 | 
			
		||||
        public void Dispose()
 | 
			
		||||
        {
 | 
			
		||||
            if (_isdisposed) return;
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                Transaction2[] trans = null;
 | 
			
		||||
                lock (_trans_lock)
 | 
			
		||||
                    trans = _trans.Values.ToArray();
 | 
			
		||||
                foreach (Transaction2 tran in trans) CommitTransaction(false, tran);
 | 
			
		||||
            }
 | 
			
		||||
            catch { }
 | 
			
		||||
 | 
			
		||||
			ObjectPool<DbConnection>[] pools = null;
 | 
			
		||||
			for (var a = 0; a < 10; a++) {
 | 
			
		||||
				try {
 | 
			
		||||
					pools = SlavePools.ToArray();
 | 
			
		||||
					SlavePools.Clear();
 | 
			
		||||
					break;
 | 
			
		||||
				} catch {
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			if (pools != null) {
 | 
			
		||||
				foreach (var pool in pools) {
 | 
			
		||||
					try { pool.Dispose(); } catch { }
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			try { MasterPool.Dispose(); } catch { }
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
            ObjectPool<DbConnection>[] pools = null;
 | 
			
		||||
            for (var a = 0; a < 10; a++)
 | 
			
		||||
            {
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                    pools = SlavePools.ToArray();
 | 
			
		||||
                    SlavePools.Clear();
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
                catch
 | 
			
		||||
                {
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (pools != null)
 | 
			
		||||
            {
 | 
			
		||||
                foreach (var pool in pools)
 | 
			
		||||
                {
 | 
			
		||||
                    try { pool.Dispose(); } catch { }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            try { MasterPool.Dispose(); } catch { }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -2,21 +2,25 @@
 | 
			
		||||
using System.Collections.Concurrent;
 | 
			
		||||
using System.Text.RegularExpressions;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider {
 | 
			
		||||
	partial class AdoProvider {
 | 
			
		||||
		public abstract object AddslashesProcessParam(object param, Type mapType);
 | 
			
		||||
		public string Addslashes(string filter, params object[] parms) {
 | 
			
		||||
			if (filter == null || parms == null) return string.Empty;
 | 
			
		||||
			if (parms.Length == 0) return filter;
 | 
			
		||||
			var nparms = new object[parms.Length];
 | 
			
		||||
			for (int a = 0; a < parms.Length; a++) {
 | 
			
		||||
				if (parms[a] == null)
 | 
			
		||||
					filter = _dicAddslashesReplaceIsNull.GetOrAdd(a, b => new Regex(@"\s*(=|IN)\s*\{" + b + @"\}", RegexOptions.IgnoreCase | RegexOptions.Compiled))
 | 
			
		||||
						.Replace(filter, $" IS {{{a}}}");
 | 
			
		||||
				nparms[a] = AddslashesProcessParam(parms[a], null);
 | 
			
		||||
			}
 | 
			
		||||
			try { string ret = string.Format(filter, nparms); return ret; } catch { return filter; }
 | 
			
		||||
		}
 | 
			
		||||
		static ConcurrentDictionary<int, Regex> _dicAddslashesReplaceIsNull = new ConcurrentDictionary<int, Regex>();
 | 
			
		||||
	}
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
{
 | 
			
		||||
    partial class AdoProvider
 | 
			
		||||
    {
 | 
			
		||||
        public abstract object AddslashesProcessParam(object param, Type mapType);
 | 
			
		||||
        public string Addslashes(string filter, params object[] parms)
 | 
			
		||||
        {
 | 
			
		||||
            if (filter == null || parms == null) return string.Empty;
 | 
			
		||||
            if (parms.Length == 0) return filter;
 | 
			
		||||
            var nparms = new object[parms.Length];
 | 
			
		||||
            for (int a = 0; a < parms.Length; a++)
 | 
			
		||||
            {
 | 
			
		||||
                if (parms[a] == null)
 | 
			
		||||
                    filter = _dicAddslashesReplaceIsNull.GetOrAdd(a, b => new Regex(@"\s*(=|IN)\s*\{" + b + @"\}", RegexOptions.IgnoreCase | RegexOptions.Compiled))
 | 
			
		||||
                        .Replace(filter, $" IS {{{a}}}");
 | 
			
		||||
                nparms[a] = AddslashesProcessParam(parms[a], null);
 | 
			
		||||
            }
 | 
			
		||||
            try { string ret = string.Format(filter, nparms); return ret; } catch { return filter; }
 | 
			
		||||
        }
 | 
			
		||||
        static ConcurrentDictionary<int, Regex> _dicAddslashesReplaceIsNull = new ConcurrentDictionary<int, Regex>();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,16 +4,18 @@ using System.Collections.Generic;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
using System.Text;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider {
 | 
			
		||||
	public class AopProvider : IAop {
 | 
			
		||||
		public EventHandler<Aop.ToListEventArgs> ToList { get; set; }
 | 
			
		||||
		public EventHandler<Aop.WhereEventArgs> Where { get; set; }
 | 
			
		||||
		public EventHandler<Aop.ParseExpressionEventArgs> ParseExpression { get; set; }
 | 
			
		||||
		public EventHandler<Aop.ConfigEntityEventArgs> ConfigEntity { get; set; }
 | 
			
		||||
		public EventHandler<Aop.ConfigEntityPropertyEventArgs> ConfigEntityProperty { get; set; }
 | 
			
		||||
		public EventHandler<Aop.CurdBeforeEventArgs> CurdBefore { get; set; }
 | 
			
		||||
		public EventHandler<Aop.CurdAfterEventArgs> CurdAfter { get; set; }
 | 
			
		||||
		public EventHandler<Aop.SyncStructureBeforeEventArgs> SyncStructureBefore { get; set; }
 | 
			
		||||
		public EventHandler<Aop.SyncStructureAfterEventArgs> SyncStructureAfter { get; set; }
 | 
			
		||||
	}
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
{
 | 
			
		||||
    public class AopProvider : IAop
 | 
			
		||||
    {
 | 
			
		||||
        public EventHandler<Aop.ToListEventArgs> ToList { get; set; }
 | 
			
		||||
        public EventHandler<Aop.WhereEventArgs> Where { get; set; }
 | 
			
		||||
        public EventHandler<Aop.ParseExpressionEventArgs> ParseExpression { get; set; }
 | 
			
		||||
        public EventHandler<Aop.ConfigEntityEventArgs> ConfigEntity { get; set; }
 | 
			
		||||
        public EventHandler<Aop.ConfigEntityPropertyEventArgs> ConfigEntityProperty { get; set; }
 | 
			
		||||
        public EventHandler<Aop.CurdBeforeEventArgs> CurdBefore { get; set; }
 | 
			
		||||
        public EventHandler<Aop.CurdAfterEventArgs> CurdAfter { get; set; }
 | 
			
		||||
        public EventHandler<Aop.SyncStructureBeforeEventArgs> SyncStructureBefore { get; set; }
 | 
			
		||||
        public EventHandler<Aop.SyncStructureAfterEventArgs> SyncStructureAfter { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -11,65 +11,76 @@ using System.Linq.Expressions;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider {
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	public abstract partial class CodeFirstProvider : ICodeFirst {
 | 
			
		||||
    public abstract partial class CodeFirstProvider : ICodeFirst
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
		protected IFreeSql _orm;
 | 
			
		||||
		protected CommonUtils _commonUtils;
 | 
			
		||||
		protected CommonExpression _commonExpression;
 | 
			
		||||
		public CodeFirstProvider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression) {
 | 
			
		||||
			_orm = orm;
 | 
			
		||||
			_commonUtils = commonUtils;
 | 
			
		||||
			_commonExpression = commonExpression;
 | 
			
		||||
		}
 | 
			
		||||
        protected IFreeSql _orm;
 | 
			
		||||
        protected CommonUtils _commonUtils;
 | 
			
		||||
        protected CommonExpression _commonExpression;
 | 
			
		||||
        public CodeFirstProvider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression)
 | 
			
		||||
        {
 | 
			
		||||
            _orm = orm;
 | 
			
		||||
            _commonUtils = commonUtils;
 | 
			
		||||
            _commonExpression = commonExpression;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		public bool IsAutoSyncStructure { get; set; } = false;
 | 
			
		||||
		public bool IsSyncStructureToLower { get; set; } = false;
 | 
			
		||||
		public bool IsSyncStructureToUpper { get; set; } = false;
 | 
			
		||||
		public bool IsConfigEntityFromDbFirst { get; set; } = false;
 | 
			
		||||
		public bool IsNoneCommandParameter { get; set; } = false;
 | 
			
		||||
		public bool IsLazyLoading { get; set; } = false;
 | 
			
		||||
        public bool IsAutoSyncStructure { get; set; } = false;
 | 
			
		||||
        public bool IsSyncStructureToLower { get; set; } = false;
 | 
			
		||||
        public bool IsSyncStructureToUpper { get; set; } = false;
 | 
			
		||||
        public bool IsConfigEntityFromDbFirst { get; set; } = false;
 | 
			
		||||
        public bool IsNoneCommandParameter { get; set; } = false;
 | 
			
		||||
        public bool IsLazyLoading { get; set; } = false;
 | 
			
		||||
 | 
			
		||||
		public abstract (int type, string dbtype, string dbtypeFull, bool? isnullable, object defaultValue)? GetDbInfo(Type type);
 | 
			
		||||
        public abstract (int type, string dbtype, string dbtypeFull, bool? isnullable, object defaultValue)? GetDbInfo(Type type);
 | 
			
		||||
 | 
			
		||||
		public ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity) => _commonUtils.ConfigEntity(entity);
 | 
			
		||||
		public ICodeFirst ConfigEntity(Type type, Action<TableFluent> entity) => _commonUtils.ConfigEntity(type, entity);
 | 
			
		||||
		public TableAttribute GetConfigEntity(Type type) => _commonUtils.GetConfigEntity(type);
 | 
			
		||||
		public TableInfo GetTableByEntity(Type type) => _commonUtils.GetTableByEntity(type);
 | 
			
		||||
        public ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity) => _commonUtils.ConfigEntity(entity);
 | 
			
		||||
        public ICodeFirst ConfigEntity(Type type, Action<TableFluent> entity) => _commonUtils.ConfigEntity(type, entity);
 | 
			
		||||
        public TableAttribute GetConfigEntity(Type type) => _commonUtils.GetConfigEntity(type);
 | 
			
		||||
        public TableInfo GetTableByEntity(Type type) => _commonUtils.GetTableByEntity(type);
 | 
			
		||||
 | 
			
		||||
		public string GetComparisonDDLStatements<TEntity>() => this.GetComparisonDDLStatements(typeof(TEntity));
 | 
			
		||||
		public abstract string GetComparisonDDLStatements(params Type[] entityTypes);
 | 
			
		||||
        public string GetComparisonDDLStatements<TEntity>() => this.GetComparisonDDLStatements(typeof(TEntity));
 | 
			
		||||
        public abstract string GetComparisonDDLStatements(params Type[] entityTypes);
 | 
			
		||||
 | 
			
		||||
		static object syncStructureLock = new object();
 | 
			
		||||
		internal ConcurrentDictionary<string, bool> dicSyced = new ConcurrentDictionary<string, bool>();
 | 
			
		||||
		public bool SyncStructure<TEntity>() => this.SyncStructure(typeof(TEntity));
 | 
			
		||||
		public bool SyncStructure(params Type[] entityTypes) {
 | 
			
		||||
			if (entityTypes == null) return false;
 | 
			
		||||
			var syncTypes = entityTypes.Where(a => dicSyced.ContainsKey(a.FullName) == false && GetTableByEntity(a)?.DisableSyncStructure == false).ToArray();
 | 
			
		||||
			if (syncTypes.Any() == false) return false;
 | 
			
		||||
			var before = new Aop.SyncStructureBeforeEventArgs(entityTypes);
 | 
			
		||||
			_orm.Aop.SyncStructureBefore?.Invoke(this, before);
 | 
			
		||||
			Exception exception = null;
 | 
			
		||||
			string ddl = null;
 | 
			
		||||
			try {
 | 
			
		||||
				lock (syncStructureLock) {
 | 
			
		||||
					ddl = this.GetComparisonDDLStatements(syncTypes);
 | 
			
		||||
					if (string.IsNullOrEmpty(ddl)) {
 | 
			
		||||
						foreach (var syncType in syncTypes) dicSyced.TryAdd(syncType.FullName, true);
 | 
			
		||||
						return true;
 | 
			
		||||
					}
 | 
			
		||||
					var affrows = _orm.Ado.ExecuteNonQuery(CommandType.Text, ddl);
 | 
			
		||||
					foreach (var syncType in syncTypes) dicSyced.TryAdd(syncType.FullName, true);
 | 
			
		||||
					return affrows > 0;
 | 
			
		||||
				}
 | 
			
		||||
			} catch (Exception ex) {
 | 
			
		||||
				exception = ex;
 | 
			
		||||
				throw ex;
 | 
			
		||||
			} finally {
 | 
			
		||||
				var after = new Aop.SyncStructureAfterEventArgs(before, ddl, exception);
 | 
			
		||||
				_orm.Aop.SyncStructureAfter?.Invoke(this, after);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
        static object syncStructureLock = new object();
 | 
			
		||||
        internal ConcurrentDictionary<string, bool> dicSyced = new ConcurrentDictionary<string, bool>();
 | 
			
		||||
        public bool SyncStructure<TEntity>() => this.SyncStructure(typeof(TEntity));
 | 
			
		||||
        public bool SyncStructure(params Type[] entityTypes)
 | 
			
		||||
        {
 | 
			
		||||
            if (entityTypes == null) return false;
 | 
			
		||||
            var syncTypes = entityTypes.Where(a => dicSyced.ContainsKey(a.FullName) == false && GetTableByEntity(a)?.DisableSyncStructure == false).ToArray();
 | 
			
		||||
            if (syncTypes.Any() == false) return false;
 | 
			
		||||
            var before = new Aop.SyncStructureBeforeEventArgs(entityTypes);
 | 
			
		||||
            _orm.Aop.SyncStructureBefore?.Invoke(this, before);
 | 
			
		||||
            Exception exception = null;
 | 
			
		||||
            string ddl = null;
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                lock (syncStructureLock)
 | 
			
		||||
                {
 | 
			
		||||
                    ddl = this.GetComparisonDDLStatements(syncTypes);
 | 
			
		||||
                    if (string.IsNullOrEmpty(ddl))
 | 
			
		||||
                    {
 | 
			
		||||
                        foreach (var syncType in syncTypes) dicSyced.TryAdd(syncType.FullName, true);
 | 
			
		||||
                        return true;
 | 
			
		||||
                    }
 | 
			
		||||
                    var affrows = _orm.Ado.ExecuteNonQuery(CommandType.Text, ddl);
 | 
			
		||||
                    foreach (var syncType in syncTypes) dicSyced.TryAdd(syncType.FullName, true);
 | 
			
		||||
                    return affrows > 0;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
                exception = ex;
 | 
			
		||||
                throw ex;
 | 
			
		||||
            }
 | 
			
		||||
            finally
 | 
			
		||||
            {
 | 
			
		||||
                var after = new Aop.SyncStructureAfterEventArgs(before, ddl, exception);
 | 
			
		||||
                _orm.Aop.SyncStructureAfter?.Invoke(this, after);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -7,119 +7,140 @@ using System.Linq.Expressions;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider {
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	public abstract partial class DeleteProvider<T1> : IDelete<T1> where T1 : class {
 | 
			
		||||
		protected IFreeSql _orm;
 | 
			
		||||
		protected CommonUtils _commonUtils;
 | 
			
		||||
		protected CommonExpression _commonExpression;
 | 
			
		||||
		protected TableInfo _table;
 | 
			
		||||
		protected Func<string, string> _tableRule;
 | 
			
		||||
		protected StringBuilder _where = new StringBuilder();
 | 
			
		||||
		protected int _whereTimes = 0;
 | 
			
		||||
		protected List<DbParameter> _params = new List<DbParameter>();
 | 
			
		||||
		protected DbTransaction _transaction;
 | 
			
		||||
		protected DbConnection _connection;
 | 
			
		||||
    public abstract partial class DeleteProvider<T1> : IDelete<T1> where T1 : class
 | 
			
		||||
    {
 | 
			
		||||
        protected IFreeSql _orm;
 | 
			
		||||
        protected CommonUtils _commonUtils;
 | 
			
		||||
        protected CommonExpression _commonExpression;
 | 
			
		||||
        protected TableInfo _table;
 | 
			
		||||
        protected Func<string, string> _tableRule;
 | 
			
		||||
        protected StringBuilder _where = new StringBuilder();
 | 
			
		||||
        protected int _whereTimes = 0;
 | 
			
		||||
        protected List<DbParameter> _params = new List<DbParameter>();
 | 
			
		||||
        protected DbTransaction _transaction;
 | 
			
		||||
        protected DbConnection _connection;
 | 
			
		||||
 | 
			
		||||
		public DeleteProvider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) {
 | 
			
		||||
			_orm = orm;
 | 
			
		||||
			_commonUtils = commonUtils;
 | 
			
		||||
			_commonExpression = commonExpression;
 | 
			
		||||
			_table = _commonUtils.GetTableByEntity(typeof(T1));
 | 
			
		||||
			this.Where(_commonUtils.WhereObject(_table, "", dywhere));
 | 
			
		||||
			if (_orm.CodeFirst.IsAutoSyncStructure && typeof(T1) != typeof(object)) _orm.CodeFirst.SyncStructure<T1>();
 | 
			
		||||
		}
 | 
			
		||||
        public DeleteProvider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere)
 | 
			
		||||
        {
 | 
			
		||||
            _orm = orm;
 | 
			
		||||
            _commonUtils = commonUtils;
 | 
			
		||||
            _commonExpression = commonExpression;
 | 
			
		||||
            _table = _commonUtils.GetTableByEntity(typeof(T1));
 | 
			
		||||
            this.Where(_commonUtils.WhereObject(_table, "", dywhere));
 | 
			
		||||
            if (_orm.CodeFirst.IsAutoSyncStructure && typeof(T1) != typeof(object)) _orm.CodeFirst.SyncStructure<T1>();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		protected void ClearData() {
 | 
			
		||||
			_where.Clear();
 | 
			
		||||
			_whereTimes = 0;
 | 
			
		||||
			_params.Clear();
 | 
			
		||||
		}
 | 
			
		||||
        protected void ClearData()
 | 
			
		||||
        {
 | 
			
		||||
            _where.Clear();
 | 
			
		||||
            _whereTimes = 0;
 | 
			
		||||
            _params.Clear();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		public IDelete<T1> WithTransaction(DbTransaction transaction) {
 | 
			
		||||
			_transaction = transaction;
 | 
			
		||||
			_connection = _transaction?.Connection;
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
		public IDelete<T1> WithConnection(DbConnection connection) {
 | 
			
		||||
			if (_transaction?.Connection != connection) _transaction = null;
 | 
			
		||||
			_connection = connection;
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
        public IDelete<T1> WithTransaction(DbTransaction transaction)
 | 
			
		||||
        {
 | 
			
		||||
            _transaction = transaction;
 | 
			
		||||
            _connection = _transaction?.Connection;
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
        public IDelete<T1> WithConnection(DbConnection connection)
 | 
			
		||||
        {
 | 
			
		||||
            if (_transaction?.Connection != connection) _transaction = null;
 | 
			
		||||
            _connection = connection;
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		public int ExecuteAffrows() {
 | 
			
		||||
			var sql = this.ToSql();
 | 
			
		||||
			if (string.IsNullOrEmpty(sql)) return 0;
 | 
			
		||||
			var dbParms = _params.ToArray();
 | 
			
		||||
			var before = new Aop.CurdBeforeEventArgs(_table.Type, Aop.CurdType.Delete, sql, dbParms);
 | 
			
		||||
			_orm.Aop.CurdBefore?.Invoke(this, before);
 | 
			
		||||
			var affrows = 0;
 | 
			
		||||
			Exception exception = null;
 | 
			
		||||
			try {
 | 
			
		||||
				affrows = _orm.Ado.ExecuteNonQuery(_connection, _transaction, CommandType.Text, sql, dbParms);
 | 
			
		||||
			} catch (Exception ex) {
 | 
			
		||||
				exception = ex;
 | 
			
		||||
				throw ex;
 | 
			
		||||
			} finally {
 | 
			
		||||
				var after = new Aop.CurdAfterEventArgs(before, exception, affrows);
 | 
			
		||||
				_orm.Aop.CurdAfter?.Invoke(this, after);
 | 
			
		||||
			}
 | 
			
		||||
			this.ClearData();
 | 
			
		||||
			return affrows;
 | 
			
		||||
		}
 | 
			
		||||
		async public Task<int> ExecuteAffrowsAsync() {
 | 
			
		||||
			var sql = this.ToSql();
 | 
			
		||||
			if (string.IsNullOrEmpty(sql)) return 0;
 | 
			
		||||
			var dbParms = _params.ToArray();
 | 
			
		||||
			var before = new Aop.CurdBeforeEventArgs(_table.Type, Aop.CurdType.Delete, sql, dbParms);
 | 
			
		||||
			_orm.Aop.CurdBefore?.Invoke(this, before);
 | 
			
		||||
			var affrows = 0;
 | 
			
		||||
			Exception exception = null;
 | 
			
		||||
			try {
 | 
			
		||||
				affrows = await _orm.Ado.ExecuteNonQueryAsync(_connection, _transaction, CommandType.Text, sql, dbParms);
 | 
			
		||||
			} catch (Exception ex) {
 | 
			
		||||
				exception = ex;
 | 
			
		||||
				throw ex;
 | 
			
		||||
			} finally {
 | 
			
		||||
				var after = new Aop.CurdAfterEventArgs(before, exception, affrows);
 | 
			
		||||
				_orm.Aop.CurdAfter?.Invoke(this, after);
 | 
			
		||||
			}
 | 
			
		||||
			this.ClearData();
 | 
			
		||||
			return affrows;
 | 
			
		||||
		}
 | 
			
		||||
		public abstract List<T1> ExecuteDeleted();
 | 
			
		||||
		public abstract Task<List<T1>> ExecuteDeletedAsync();
 | 
			
		||||
        public int ExecuteAffrows()
 | 
			
		||||
        {
 | 
			
		||||
            var sql = this.ToSql();
 | 
			
		||||
            if (string.IsNullOrEmpty(sql)) return 0;
 | 
			
		||||
            var dbParms = _params.ToArray();
 | 
			
		||||
            var before = new Aop.CurdBeforeEventArgs(_table.Type, Aop.CurdType.Delete, sql, dbParms);
 | 
			
		||||
            _orm.Aop.CurdBefore?.Invoke(this, before);
 | 
			
		||||
            var affrows = 0;
 | 
			
		||||
            Exception exception = null;
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                affrows = _orm.Ado.ExecuteNonQuery(_connection, _transaction, CommandType.Text, sql, dbParms);
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
                exception = ex;
 | 
			
		||||
                throw ex;
 | 
			
		||||
            }
 | 
			
		||||
            finally
 | 
			
		||||
            {
 | 
			
		||||
                var after = new Aop.CurdAfterEventArgs(before, exception, affrows);
 | 
			
		||||
                _orm.Aop.CurdAfter?.Invoke(this, after);
 | 
			
		||||
            }
 | 
			
		||||
            this.ClearData();
 | 
			
		||||
            return affrows;
 | 
			
		||||
        }
 | 
			
		||||
        async public Task<int> ExecuteAffrowsAsync()
 | 
			
		||||
        {
 | 
			
		||||
            var sql = this.ToSql();
 | 
			
		||||
            if (string.IsNullOrEmpty(sql)) return 0;
 | 
			
		||||
            var dbParms = _params.ToArray();
 | 
			
		||||
            var before = new Aop.CurdBeforeEventArgs(_table.Type, Aop.CurdType.Delete, sql, dbParms);
 | 
			
		||||
            _orm.Aop.CurdBefore?.Invoke(this, before);
 | 
			
		||||
            var affrows = 0;
 | 
			
		||||
            Exception exception = null;
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                affrows = await _orm.Ado.ExecuteNonQueryAsync(_connection, _transaction, CommandType.Text, sql, dbParms);
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
                exception = ex;
 | 
			
		||||
                throw ex;
 | 
			
		||||
            }
 | 
			
		||||
            finally
 | 
			
		||||
            {
 | 
			
		||||
                var after = new Aop.CurdAfterEventArgs(before, exception, affrows);
 | 
			
		||||
                _orm.Aop.CurdAfter?.Invoke(this, after);
 | 
			
		||||
            }
 | 
			
		||||
            this.ClearData();
 | 
			
		||||
            return affrows;
 | 
			
		||||
        }
 | 
			
		||||
        public abstract List<T1> ExecuteDeleted();
 | 
			
		||||
        public abstract Task<List<T1>> ExecuteDeletedAsync();
 | 
			
		||||
 | 
			
		||||
		public IDelete<T1> Where(Expression<Func<T1, bool>> exp) => this.Where(_commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, null, exp?.Body, null));
 | 
			
		||||
		public IDelete<T1> Where(string sql, object parms = null) {
 | 
			
		||||
			if (string.IsNullOrEmpty(sql)) return this;
 | 
			
		||||
			var args = new Aop.WhereEventArgs(sql, parms);
 | 
			
		||||
			_orm.Aop.Where?.Invoke(this, new Aop.WhereEventArgs(sql, parms));
 | 
			
		||||
			if (args.IsCancel == true) return this;
 | 
			
		||||
        public IDelete<T1> Where(Expression<Func<T1, bool>> exp) => this.Where(_commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, null, exp?.Body, null));
 | 
			
		||||
        public IDelete<T1> Where(string sql, object parms = null)
 | 
			
		||||
        {
 | 
			
		||||
            if (string.IsNullOrEmpty(sql)) return this;
 | 
			
		||||
            var args = new Aop.WhereEventArgs(sql, parms);
 | 
			
		||||
            _orm.Aop.Where?.Invoke(this, new Aop.WhereEventArgs(sql, parms));
 | 
			
		||||
            if (args.IsCancel == true) return this;
 | 
			
		||||
 | 
			
		||||
			if (++_whereTimes > 1) _where.Append(" AND ");
 | 
			
		||||
			_where.Append("(").Append(sql).Append(")");
 | 
			
		||||
			if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject(sql, parms));
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
		public IDelete<T1> Where(T1 item) => this.Where(new[] { item });
 | 
			
		||||
		public IDelete<T1> Where(IEnumerable<T1> items) => this.Where(_commonUtils.WhereItems(_table, "", items));
 | 
			
		||||
		public IDelete<T1> WhereExists<TEntity2>(ISelect<TEntity2> select, bool notExists = false) where TEntity2 : class => this.Where($"{(notExists ? "NOT " : "")}EXISTS({select.ToSql("1")})");
 | 
			
		||||
		public IDelete<T1> WhereDynamic(object dywhere) => this.Where(_commonUtils.WhereObject(_table, "", dywhere));
 | 
			
		||||
            if (++_whereTimes > 1) _where.Append(" AND ");
 | 
			
		||||
            _where.Append("(").Append(sql).Append(")");
 | 
			
		||||
            if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject(sql, parms));
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
        public IDelete<T1> Where(T1 item) => this.Where(new[] { item });
 | 
			
		||||
        public IDelete<T1> Where(IEnumerable<T1> items) => this.Where(_commonUtils.WhereItems(_table, "", items));
 | 
			
		||||
        public IDelete<T1> WhereExists<TEntity2>(ISelect<TEntity2> select, bool notExists = false) where TEntity2 : class => this.Where($"{(notExists ? "NOT " : "")}EXISTS({select.ToSql("1")})");
 | 
			
		||||
        public IDelete<T1> WhereDynamic(object dywhere) => this.Where(_commonUtils.WhereObject(_table, "", dywhere));
 | 
			
		||||
 | 
			
		||||
		public IDelete<T1> AsTable(Func<string, string> tableRule) {
 | 
			
		||||
			_tableRule = tableRule;
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
		public IDelete<T1> AsType(Type entityType) {
 | 
			
		||||
			if (entityType == typeof(object)) throw new Exception("IDelete.AsType 参数不支持指定为 object");
 | 
			
		||||
			if (entityType == _table.Type) return this;
 | 
			
		||||
			var newtb = _commonUtils.GetTableByEntity(entityType);
 | 
			
		||||
			_table = newtb ?? throw new Exception("IDelete.AsType 参数错误,请传入正确的实体类型");
 | 
			
		||||
			if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(entityType);
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
        public IDelete<T1> AsTable(Func<string, string> tableRule)
 | 
			
		||||
        {
 | 
			
		||||
            _tableRule = tableRule;
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
        public IDelete<T1> AsType(Type entityType)
 | 
			
		||||
        {
 | 
			
		||||
            if (entityType == typeof(object)) throw new Exception("IDelete.AsType 参数不支持指定为 object");
 | 
			
		||||
            if (entityType == _table.Type) return this;
 | 
			
		||||
            var newtb = _commonUtils.GetTableByEntity(entityType);
 | 
			
		||||
            _table = newtb ?? throw new Exception("IDelete.AsType 参数错误,请传入正确的实体类型");
 | 
			
		||||
            if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(entityType);
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		public string ToSql() => _whereTimes <= 0 ? null : new StringBuilder().Append("DELETE FROM ").Append(_commonUtils.QuoteSqlName(_tableRule?.Invoke(_table.DbName) ?? _table.DbName)).Append(" WHERE ").Append(_where).ToString();
 | 
			
		||||
	}
 | 
			
		||||
        public string ToSql() => _whereTimes <= 0 ? null : new StringBuilder().Append("DELETE FROM ").Append(_commonUtils.QuoteSqlName(_tableRule?.Invoke(_table.DbName) ?? _table.DbName)).Append(" WHERE ").Append(_where).ToString();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -9,436 +9,545 @@ using System.Linq.Expressions;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider {
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	public abstract partial class InsertProvider<T1> : IInsert<T1> where T1 : class {
 | 
			
		||||
		protected IFreeSql _orm;
 | 
			
		||||
		protected CommonUtils _commonUtils;
 | 
			
		||||
		protected CommonExpression _commonExpression;
 | 
			
		||||
		protected List<T1> _source = new List<T1>();
 | 
			
		||||
		protected Dictionary<string, bool> _ignore = new Dictionary<string, bool>(StringComparer.CurrentCultureIgnoreCase);
 | 
			
		||||
		protected TableInfo _table;
 | 
			
		||||
		protected Func<string, string> _tableRule;
 | 
			
		||||
		protected bool _noneParameter;
 | 
			
		||||
		protected DbParameter[] _params;
 | 
			
		||||
		protected DbTransaction _transaction;
 | 
			
		||||
		protected DbConnection _connection;
 | 
			
		||||
    public abstract partial class InsertProvider<T1> : IInsert<T1> where T1 : class
 | 
			
		||||
    {
 | 
			
		||||
        protected IFreeSql _orm;
 | 
			
		||||
        protected CommonUtils _commonUtils;
 | 
			
		||||
        protected CommonExpression _commonExpression;
 | 
			
		||||
        protected List<T1> _source = new List<T1>();
 | 
			
		||||
        protected Dictionary<string, bool> _ignore = new Dictionary<string, bool>(StringComparer.CurrentCultureIgnoreCase);
 | 
			
		||||
        protected TableInfo _table;
 | 
			
		||||
        protected Func<string, string> _tableRule;
 | 
			
		||||
        protected bool _noneParameter;
 | 
			
		||||
        protected DbParameter[] _params;
 | 
			
		||||
        protected DbTransaction _transaction;
 | 
			
		||||
        protected DbConnection _connection;
 | 
			
		||||
 | 
			
		||||
		public InsertProvider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression) {
 | 
			
		||||
			_orm = orm;
 | 
			
		||||
			_commonUtils = commonUtils;
 | 
			
		||||
			_commonExpression = commonExpression;
 | 
			
		||||
			_table = _commonUtils.GetTableByEntity(typeof(T1));
 | 
			
		||||
			_noneParameter = _orm.CodeFirst.IsNoneCommandParameter;
 | 
			
		||||
			if (_orm.CodeFirst.IsAutoSyncStructure && typeof(T1) != typeof(object)) _orm.CodeFirst.SyncStructure<T1>();
 | 
			
		||||
		}
 | 
			
		||||
        public InsertProvider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression)
 | 
			
		||||
        {
 | 
			
		||||
            _orm = orm;
 | 
			
		||||
            _commonUtils = commonUtils;
 | 
			
		||||
            _commonExpression = commonExpression;
 | 
			
		||||
            _table = _commonUtils.GetTableByEntity(typeof(T1));
 | 
			
		||||
            _noneParameter = _orm.CodeFirst.IsNoneCommandParameter;
 | 
			
		||||
            if (_orm.CodeFirst.IsAutoSyncStructure && typeof(T1) != typeof(object)) _orm.CodeFirst.SyncStructure<T1>();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		protected void ClearData() {
 | 
			
		||||
			_source.Clear();
 | 
			
		||||
			_ignore.Clear();
 | 
			
		||||
			_params = null;
 | 
			
		||||
		}
 | 
			
		||||
        protected void ClearData()
 | 
			
		||||
        {
 | 
			
		||||
            _source.Clear();
 | 
			
		||||
            _ignore.Clear();
 | 
			
		||||
            _params = null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		public IInsert<T1> WithTransaction(DbTransaction transaction) {
 | 
			
		||||
			_transaction = transaction;
 | 
			
		||||
			_connection = _transaction?.Connection;
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
		public IInsert<T1> WithConnection(DbConnection connection) {
 | 
			
		||||
			if (_transaction?.Connection != connection) _transaction = null;
 | 
			
		||||
			_connection = connection;
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
        public IInsert<T1> WithTransaction(DbTransaction transaction)
 | 
			
		||||
        {
 | 
			
		||||
            _transaction = transaction;
 | 
			
		||||
            _connection = _transaction?.Connection;
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
        public IInsert<T1> WithConnection(DbConnection connection)
 | 
			
		||||
        {
 | 
			
		||||
            if (_transaction?.Connection != connection) _transaction = null;
 | 
			
		||||
            _connection = connection;
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		public IInsert<T1> NoneParameter() {
 | 
			
		||||
			_noneParameter = true;
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
        public IInsert<T1> NoneParameter()
 | 
			
		||||
        {
 | 
			
		||||
            _noneParameter = true;
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		public IInsert<T1> AppendData(T1 source) {
 | 
			
		||||
			if (source != null) _source.Add(source);
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
		public IInsert<T1> AppendData(T1[] source) {
 | 
			
		||||
			if (source != null) _source.AddRange(source);
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
		public IInsert<T1> AppendData(IEnumerable<T1> source) {
 | 
			
		||||
			if (source != null) _source.AddRange(source.Where(a => a != null));
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
        public IInsert<T1> AppendData(T1 source)
 | 
			
		||||
        {
 | 
			
		||||
            if (source != null) _source.Add(source);
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
        public IInsert<T1> AppendData(T1[] source)
 | 
			
		||||
        {
 | 
			
		||||
            if (source != null) _source.AddRange(source);
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
        public IInsert<T1> AppendData(IEnumerable<T1> source)
 | 
			
		||||
        {
 | 
			
		||||
            if (source != null) _source.AddRange(source.Where(a => a != null));
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		#region 参数化数据限制,或values数量限制
 | 
			
		||||
		protected List<T1>[] SplitSource(int valuesLimit, int parameterLimit) {
 | 
			
		||||
			valuesLimit = valuesLimit - 1;
 | 
			
		||||
			parameterLimit = parameterLimit - 1;
 | 
			
		||||
			if (_source == null || _source.Any() == false) return new List<T1>[0];
 | 
			
		||||
			if (_source.Count == 1) return new[] { _source };
 | 
			
		||||
			if (_noneParameter) {
 | 
			
		||||
				if (_source.Count < valuesLimit) return new[] { _source };
 | 
			
		||||
        #region 参数化数据限制,或values数量限制
 | 
			
		||||
        protected List<T1>[] SplitSource(int valuesLimit, int parameterLimit)
 | 
			
		||||
        {
 | 
			
		||||
            valuesLimit = valuesLimit - 1;
 | 
			
		||||
            parameterLimit = parameterLimit - 1;
 | 
			
		||||
            if (_source == null || _source.Any() == false) return new List<T1>[0];
 | 
			
		||||
            if (_source.Count == 1) return new[] { _source };
 | 
			
		||||
            if (_noneParameter)
 | 
			
		||||
            {
 | 
			
		||||
                if (_source.Count < valuesLimit) return new[] { _source };
 | 
			
		||||
 | 
			
		||||
				var execCount = (int)Math.Ceiling(1.0 * _source.Count / valuesLimit);
 | 
			
		||||
				var ret = new List<T1>[execCount];
 | 
			
		||||
				for (var a = 0; a < execCount; a++) {
 | 
			
		||||
					var subSource = new List<T1>();
 | 
			
		||||
					subSource = _source.GetRange(a * valuesLimit, Math.Min(valuesLimit, _source.Count - a * valuesLimit));
 | 
			
		||||
					ret[a] = subSource;
 | 
			
		||||
				}
 | 
			
		||||
				return ret;
 | 
			
		||||
			} else {
 | 
			
		||||
				var colSum = _table.Columns.Count - _ignore.Count;
 | 
			
		||||
				var takeMax = parameterLimit / colSum;
 | 
			
		||||
				var pamTotal = colSum * _source.Count;
 | 
			
		||||
				if (pamTotal < parameterLimit) return new[] { _source };
 | 
			
		||||
                var execCount = (int)Math.Ceiling(1.0 * _source.Count / valuesLimit);
 | 
			
		||||
                var ret = new List<T1>[execCount];
 | 
			
		||||
                for (var a = 0; a < execCount; a++)
 | 
			
		||||
                {
 | 
			
		||||
                    var subSource = new List<T1>();
 | 
			
		||||
                    subSource = _source.GetRange(a * valuesLimit, Math.Min(valuesLimit, _source.Count - a * valuesLimit));
 | 
			
		||||
                    ret[a] = subSource;
 | 
			
		||||
                }
 | 
			
		||||
                return ret;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                var colSum = _table.Columns.Count - _ignore.Count;
 | 
			
		||||
                var takeMax = parameterLimit / colSum;
 | 
			
		||||
                var pamTotal = colSum * _source.Count;
 | 
			
		||||
                if (pamTotal < parameterLimit) return new[] { _source };
 | 
			
		||||
 | 
			
		||||
				var execCount = (int)Math.Ceiling(1.0 * pamTotal / takeMax / colSum);
 | 
			
		||||
				var ret = new List<T1>[execCount];
 | 
			
		||||
				for (var a = 0; a < execCount; a++) {
 | 
			
		||||
					var subSource = new List<T1>();
 | 
			
		||||
					subSource = _source.GetRange(a * takeMax, Math.Min(takeMax, _source.Count - a * takeMax));
 | 
			
		||||
					ret[a] = subSource;
 | 
			
		||||
				}
 | 
			
		||||
				return ret;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		protected int SplitExecuteAffrows(int valuesLimit, int parameterLimit) {
 | 
			
		||||
			var ss = SplitSource(valuesLimit, parameterLimit);
 | 
			
		||||
			var ret = 0;
 | 
			
		||||
			if (ss.Any() == false) {
 | 
			
		||||
				ClearData();
 | 
			
		||||
				return ret;
 | 
			
		||||
			}
 | 
			
		||||
			if (ss.Length == 1) {
 | 
			
		||||
				ret = this.RawExecuteAffrows();
 | 
			
		||||
				ClearData();
 | 
			
		||||
				return ret;
 | 
			
		||||
			}
 | 
			
		||||
			if (_transaction != null) {
 | 
			
		||||
				for (var a = 0; a < ss.Length; a++) {
 | 
			
		||||
					_source = ss[a];
 | 
			
		||||
					ret += this.RawExecuteAffrows();
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				using (var conn = _orm.Ado.MasterPool.Get()) {
 | 
			
		||||
					_transaction = conn.Value.BeginTransaction();
 | 
			
		||||
					try {
 | 
			
		||||
						for (var a = 0; a < ss.Length; a++) {
 | 
			
		||||
							_source = ss[a];
 | 
			
		||||
							ret += this.RawExecuteAffrows();
 | 
			
		||||
						}
 | 
			
		||||
						_transaction.Commit();
 | 
			
		||||
					} catch {
 | 
			
		||||
						_transaction.Rollback();
 | 
			
		||||
						throw;
 | 
			
		||||
					}
 | 
			
		||||
					_transaction = null;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			ClearData();
 | 
			
		||||
			return ret;
 | 
			
		||||
		}
 | 
			
		||||
		async protected Task<int> SplitExecuteAffrowsAsync(int valuesLimit, int parameterLimit) {
 | 
			
		||||
			var ss = SplitSource(valuesLimit, parameterLimit);
 | 
			
		||||
			var ret = 0;
 | 
			
		||||
			if (ss.Any() == false) {
 | 
			
		||||
				ClearData();
 | 
			
		||||
				return ret;
 | 
			
		||||
			}
 | 
			
		||||
			if (ss.Length == 1) {
 | 
			
		||||
				ret = await this.RawExecuteAffrowsAsync();
 | 
			
		||||
				ClearData();
 | 
			
		||||
				return ret;
 | 
			
		||||
			}
 | 
			
		||||
			if (_transaction != null) {
 | 
			
		||||
				for (var a = 0; a < ss.Length; a++) {
 | 
			
		||||
					_source = ss[a];
 | 
			
		||||
					ret += await this.RawExecuteAffrowsAsync();
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				using (var conn = await _orm.Ado.MasterPool.GetAsync()) {
 | 
			
		||||
					_transaction = conn.Value.BeginTransaction();
 | 
			
		||||
					try {
 | 
			
		||||
						for (var a = 0; a < ss.Length; a++) {
 | 
			
		||||
							_source = ss[a];
 | 
			
		||||
							ret += await this.RawExecuteAffrowsAsync();
 | 
			
		||||
						}
 | 
			
		||||
						_transaction.Commit();
 | 
			
		||||
					} catch {
 | 
			
		||||
						_transaction.Rollback();
 | 
			
		||||
						throw;
 | 
			
		||||
					}
 | 
			
		||||
					_transaction = null;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			ClearData();
 | 
			
		||||
			return ret;
 | 
			
		||||
		}
 | 
			
		||||
		protected long SplitExecuteIdentity(int valuesLimit, int parameterLimit) {
 | 
			
		||||
			var ss = SplitSource(valuesLimit, parameterLimit);
 | 
			
		||||
			long ret = 0;
 | 
			
		||||
			if (ss.Any() == false) {
 | 
			
		||||
				ClearData();
 | 
			
		||||
				return ret;
 | 
			
		||||
			}
 | 
			
		||||
			if (ss.Length == 1) {
 | 
			
		||||
				ret = this.RawExecuteIdentity();
 | 
			
		||||
				ClearData();
 | 
			
		||||
				return ret;
 | 
			
		||||
			}
 | 
			
		||||
			if (_transaction != null) {
 | 
			
		||||
				for (var a = 0; a < ss.Length; a++) {
 | 
			
		||||
					_source = ss[a];
 | 
			
		||||
					if (a < ss.Length - 1) this.RawExecuteAffrows();
 | 
			
		||||
					else ret = this.RawExecuteIdentity();
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				using (var conn = _orm.Ado.MasterPool.Get()) {
 | 
			
		||||
					_transaction = conn.Value.BeginTransaction();
 | 
			
		||||
					try {
 | 
			
		||||
						for (var a = 0; a < ss.Length; a++) {
 | 
			
		||||
							_source = ss[a];
 | 
			
		||||
							if (a < ss.Length - 1) this.RawExecuteAffrows();
 | 
			
		||||
							else ret = this.RawExecuteIdentity();
 | 
			
		||||
						}
 | 
			
		||||
						_transaction.Commit();
 | 
			
		||||
					} catch {
 | 
			
		||||
						_transaction.Rollback();
 | 
			
		||||
						throw;
 | 
			
		||||
					}
 | 
			
		||||
					_transaction = null;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			ClearData();
 | 
			
		||||
			return ret;
 | 
			
		||||
		}
 | 
			
		||||
		async protected Task<long> SplitExecuteIdentityAsync(int valuesLimit, int parameterLimit) {
 | 
			
		||||
			var ss = SplitSource(valuesLimit, parameterLimit);
 | 
			
		||||
			long ret = 0;
 | 
			
		||||
			if (ss.Any() == false) {
 | 
			
		||||
				ClearData();
 | 
			
		||||
				return ret;
 | 
			
		||||
			}
 | 
			
		||||
			if (ss.Length == 1) {
 | 
			
		||||
				ret = await this.RawExecuteIdentityAsync();
 | 
			
		||||
				ClearData();
 | 
			
		||||
				return ret;
 | 
			
		||||
			}
 | 
			
		||||
			if (_transaction != null) {
 | 
			
		||||
				for (var a = 0; a < ss.Length; a++) {
 | 
			
		||||
					_source = ss[a];
 | 
			
		||||
					if (a < ss.Length - 1) await this.RawExecuteAffrowsAsync();
 | 
			
		||||
					else ret = await this.RawExecuteIdentityAsync();
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				using (var conn = await _orm.Ado.MasterPool.GetAsync()) {
 | 
			
		||||
					_transaction = conn.Value.BeginTransaction();
 | 
			
		||||
					try {
 | 
			
		||||
						for (var a = 0; a < ss.Length; a++) {
 | 
			
		||||
							_source = ss[a];
 | 
			
		||||
							if (a < ss.Length - 1) await this.RawExecuteAffrowsAsync();
 | 
			
		||||
							else ret = await this.RawExecuteIdentityAsync();
 | 
			
		||||
						}
 | 
			
		||||
						_transaction.Commit();
 | 
			
		||||
					} catch {
 | 
			
		||||
						_transaction.Rollback();
 | 
			
		||||
						throw;
 | 
			
		||||
					}
 | 
			
		||||
					_transaction = null;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			ClearData();
 | 
			
		||||
			return ret;
 | 
			
		||||
		}
 | 
			
		||||
		protected List<T1> SplitExecuteInserted(int valuesLimit, int parameterLimit) {
 | 
			
		||||
			var ss = SplitSource(valuesLimit, parameterLimit);
 | 
			
		||||
			var ret = new List<T1>();
 | 
			
		||||
			if (ss.Any() == false) {
 | 
			
		||||
				ClearData();
 | 
			
		||||
				return ret;
 | 
			
		||||
			}
 | 
			
		||||
			if (ss.Length == 1) {
 | 
			
		||||
				ret = this.RawExecuteInserted();
 | 
			
		||||
				ClearData();
 | 
			
		||||
				return ret;
 | 
			
		||||
			}
 | 
			
		||||
			if (_transaction != null) {
 | 
			
		||||
				for (var a = 0; a < ss.Length; a++) {
 | 
			
		||||
					_source = ss[a];
 | 
			
		||||
					ret.AddRange(this.RawExecuteInserted());
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				using (var conn = _orm.Ado.MasterPool.Get()) {
 | 
			
		||||
					_transaction = conn.Value.BeginTransaction();
 | 
			
		||||
					try {
 | 
			
		||||
						for (var a = 0; a < ss.Length; a++) {
 | 
			
		||||
							_source = ss[a];
 | 
			
		||||
							ret.AddRange(this.RawExecuteInserted());
 | 
			
		||||
						}
 | 
			
		||||
						_transaction.Commit();
 | 
			
		||||
					} catch {
 | 
			
		||||
						_transaction.Rollback();
 | 
			
		||||
						throw;
 | 
			
		||||
					}
 | 
			
		||||
					_transaction = null;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			ClearData();
 | 
			
		||||
			return ret;
 | 
			
		||||
		}
 | 
			
		||||
		async protected Task<List<T1>> SplitExecuteInsertedAsync(int valuesLimit, int parameterLimit) {
 | 
			
		||||
			var ss = SplitSource(valuesLimit, parameterLimit);
 | 
			
		||||
			var ret = new List<T1>();
 | 
			
		||||
			if (ss.Any() == false) {
 | 
			
		||||
				ClearData();
 | 
			
		||||
				return ret;
 | 
			
		||||
			}
 | 
			
		||||
			if (ss.Length == 1) {
 | 
			
		||||
				ret = await this.RawExecuteInsertedAsync();
 | 
			
		||||
				ClearData();
 | 
			
		||||
				return ret;
 | 
			
		||||
			}
 | 
			
		||||
			if (_transaction != null) {
 | 
			
		||||
				for (var a = 0; a < ss.Length; a++) {
 | 
			
		||||
					_source = ss[a];
 | 
			
		||||
					ret.AddRange(await this.RawExecuteInsertedAsync());
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				using (var conn = await _orm.Ado.MasterPool.GetAsync()) {
 | 
			
		||||
					_transaction = conn.Value.BeginTransaction();
 | 
			
		||||
					try {
 | 
			
		||||
						for (var a = 0; a < ss.Length; a++) {
 | 
			
		||||
							_source = ss[a];
 | 
			
		||||
							ret.AddRange(await this.RawExecuteInsertedAsync());
 | 
			
		||||
						}
 | 
			
		||||
						_transaction.Commit();
 | 
			
		||||
					} catch {
 | 
			
		||||
						_transaction.Rollback();
 | 
			
		||||
						throw;
 | 
			
		||||
					}
 | 
			
		||||
					_transaction = null;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			ClearData();
 | 
			
		||||
			return ret;
 | 
			
		||||
		}
 | 
			
		||||
		#endregion
 | 
			
		||||
                var execCount = (int)Math.Ceiling(1.0 * pamTotal / takeMax / colSum);
 | 
			
		||||
                var ret = new List<T1>[execCount];
 | 
			
		||||
                for (var a = 0; a < execCount; a++)
 | 
			
		||||
                {
 | 
			
		||||
                    var subSource = new List<T1>();
 | 
			
		||||
                    subSource = _source.GetRange(a * takeMax, Math.Min(takeMax, _source.Count - a * takeMax));
 | 
			
		||||
                    ret[a] = subSource;
 | 
			
		||||
                }
 | 
			
		||||
                return ret;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        protected int SplitExecuteAffrows(int valuesLimit, int parameterLimit)
 | 
			
		||||
        {
 | 
			
		||||
            var ss = SplitSource(valuesLimit, parameterLimit);
 | 
			
		||||
            var ret = 0;
 | 
			
		||||
            if (ss.Any() == false)
 | 
			
		||||
            {
 | 
			
		||||
                ClearData();
 | 
			
		||||
                return ret;
 | 
			
		||||
            }
 | 
			
		||||
            if (ss.Length == 1)
 | 
			
		||||
            {
 | 
			
		||||
                ret = this.RawExecuteAffrows();
 | 
			
		||||
                ClearData();
 | 
			
		||||
                return ret;
 | 
			
		||||
            }
 | 
			
		||||
            if (_transaction != null)
 | 
			
		||||
            {
 | 
			
		||||
                for (var a = 0; a < ss.Length; a++)
 | 
			
		||||
                {
 | 
			
		||||
                    _source = ss[a];
 | 
			
		||||
                    ret += this.RawExecuteAffrows();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                using (var conn = _orm.Ado.MasterPool.Get())
 | 
			
		||||
                {
 | 
			
		||||
                    _transaction = conn.Value.BeginTransaction();
 | 
			
		||||
                    try
 | 
			
		||||
                    {
 | 
			
		||||
                        for (var a = 0; a < ss.Length; a++)
 | 
			
		||||
                        {
 | 
			
		||||
                            _source = ss[a];
 | 
			
		||||
                            ret += this.RawExecuteAffrows();
 | 
			
		||||
                        }
 | 
			
		||||
                        _transaction.Commit();
 | 
			
		||||
                    }
 | 
			
		||||
                    catch
 | 
			
		||||
                    {
 | 
			
		||||
                        _transaction.Rollback();
 | 
			
		||||
                        throw;
 | 
			
		||||
                    }
 | 
			
		||||
                    _transaction = null;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            ClearData();
 | 
			
		||||
            return ret;
 | 
			
		||||
        }
 | 
			
		||||
        async protected Task<int> SplitExecuteAffrowsAsync(int valuesLimit, int parameterLimit)
 | 
			
		||||
        {
 | 
			
		||||
            var ss = SplitSource(valuesLimit, parameterLimit);
 | 
			
		||||
            var ret = 0;
 | 
			
		||||
            if (ss.Any() == false)
 | 
			
		||||
            {
 | 
			
		||||
                ClearData();
 | 
			
		||||
                return ret;
 | 
			
		||||
            }
 | 
			
		||||
            if (ss.Length == 1)
 | 
			
		||||
            {
 | 
			
		||||
                ret = await this.RawExecuteAffrowsAsync();
 | 
			
		||||
                ClearData();
 | 
			
		||||
                return ret;
 | 
			
		||||
            }
 | 
			
		||||
            if (_transaction != null)
 | 
			
		||||
            {
 | 
			
		||||
                for (var a = 0; a < ss.Length; a++)
 | 
			
		||||
                {
 | 
			
		||||
                    _source = ss[a];
 | 
			
		||||
                    ret += await this.RawExecuteAffrowsAsync();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                using (var conn = await _orm.Ado.MasterPool.GetAsync())
 | 
			
		||||
                {
 | 
			
		||||
                    _transaction = conn.Value.BeginTransaction();
 | 
			
		||||
                    try
 | 
			
		||||
                    {
 | 
			
		||||
                        for (var a = 0; a < ss.Length; a++)
 | 
			
		||||
                        {
 | 
			
		||||
                            _source = ss[a];
 | 
			
		||||
                            ret += await this.RawExecuteAffrowsAsync();
 | 
			
		||||
                        }
 | 
			
		||||
                        _transaction.Commit();
 | 
			
		||||
                    }
 | 
			
		||||
                    catch
 | 
			
		||||
                    {
 | 
			
		||||
                        _transaction.Rollback();
 | 
			
		||||
                        throw;
 | 
			
		||||
                    }
 | 
			
		||||
                    _transaction = null;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            ClearData();
 | 
			
		||||
            return ret;
 | 
			
		||||
        }
 | 
			
		||||
        protected long SplitExecuteIdentity(int valuesLimit, int parameterLimit)
 | 
			
		||||
        {
 | 
			
		||||
            var ss = SplitSource(valuesLimit, parameterLimit);
 | 
			
		||||
            long ret = 0;
 | 
			
		||||
            if (ss.Any() == false)
 | 
			
		||||
            {
 | 
			
		||||
                ClearData();
 | 
			
		||||
                return ret;
 | 
			
		||||
            }
 | 
			
		||||
            if (ss.Length == 1)
 | 
			
		||||
            {
 | 
			
		||||
                ret = this.RawExecuteIdentity();
 | 
			
		||||
                ClearData();
 | 
			
		||||
                return ret;
 | 
			
		||||
            }
 | 
			
		||||
            if (_transaction != null)
 | 
			
		||||
            {
 | 
			
		||||
                for (var a = 0; a < ss.Length; a++)
 | 
			
		||||
                {
 | 
			
		||||
                    _source = ss[a];
 | 
			
		||||
                    if (a < ss.Length - 1) this.RawExecuteAffrows();
 | 
			
		||||
                    else ret = this.RawExecuteIdentity();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                using (var conn = _orm.Ado.MasterPool.Get())
 | 
			
		||||
                {
 | 
			
		||||
                    _transaction = conn.Value.BeginTransaction();
 | 
			
		||||
                    try
 | 
			
		||||
                    {
 | 
			
		||||
                        for (var a = 0; a < ss.Length; a++)
 | 
			
		||||
                        {
 | 
			
		||||
                            _source = ss[a];
 | 
			
		||||
                            if (a < ss.Length - 1) this.RawExecuteAffrows();
 | 
			
		||||
                            else ret = this.RawExecuteIdentity();
 | 
			
		||||
                        }
 | 
			
		||||
                        _transaction.Commit();
 | 
			
		||||
                    }
 | 
			
		||||
                    catch
 | 
			
		||||
                    {
 | 
			
		||||
                        _transaction.Rollback();
 | 
			
		||||
                        throw;
 | 
			
		||||
                    }
 | 
			
		||||
                    _transaction = null;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            ClearData();
 | 
			
		||||
            return ret;
 | 
			
		||||
        }
 | 
			
		||||
        async protected Task<long> SplitExecuteIdentityAsync(int valuesLimit, int parameterLimit)
 | 
			
		||||
        {
 | 
			
		||||
            var ss = SplitSource(valuesLimit, parameterLimit);
 | 
			
		||||
            long ret = 0;
 | 
			
		||||
            if (ss.Any() == false)
 | 
			
		||||
            {
 | 
			
		||||
                ClearData();
 | 
			
		||||
                return ret;
 | 
			
		||||
            }
 | 
			
		||||
            if (ss.Length == 1)
 | 
			
		||||
            {
 | 
			
		||||
                ret = await this.RawExecuteIdentityAsync();
 | 
			
		||||
                ClearData();
 | 
			
		||||
                return ret;
 | 
			
		||||
            }
 | 
			
		||||
            if (_transaction != null)
 | 
			
		||||
            {
 | 
			
		||||
                for (var a = 0; a < ss.Length; a++)
 | 
			
		||||
                {
 | 
			
		||||
                    _source = ss[a];
 | 
			
		||||
                    if (a < ss.Length - 1) await this.RawExecuteAffrowsAsync();
 | 
			
		||||
                    else ret = await this.RawExecuteIdentityAsync();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                using (var conn = await _orm.Ado.MasterPool.GetAsync())
 | 
			
		||||
                {
 | 
			
		||||
                    _transaction = conn.Value.BeginTransaction();
 | 
			
		||||
                    try
 | 
			
		||||
                    {
 | 
			
		||||
                        for (var a = 0; a < ss.Length; a++)
 | 
			
		||||
                        {
 | 
			
		||||
                            _source = ss[a];
 | 
			
		||||
                            if (a < ss.Length - 1) await this.RawExecuteAffrowsAsync();
 | 
			
		||||
                            else ret = await this.RawExecuteIdentityAsync();
 | 
			
		||||
                        }
 | 
			
		||||
                        _transaction.Commit();
 | 
			
		||||
                    }
 | 
			
		||||
                    catch
 | 
			
		||||
                    {
 | 
			
		||||
                        _transaction.Rollback();
 | 
			
		||||
                        throw;
 | 
			
		||||
                    }
 | 
			
		||||
                    _transaction = null;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            ClearData();
 | 
			
		||||
            return ret;
 | 
			
		||||
        }
 | 
			
		||||
        protected List<T1> SplitExecuteInserted(int valuesLimit, int parameterLimit)
 | 
			
		||||
        {
 | 
			
		||||
            var ss = SplitSource(valuesLimit, parameterLimit);
 | 
			
		||||
            var ret = new List<T1>();
 | 
			
		||||
            if (ss.Any() == false)
 | 
			
		||||
            {
 | 
			
		||||
                ClearData();
 | 
			
		||||
                return ret;
 | 
			
		||||
            }
 | 
			
		||||
            if (ss.Length == 1)
 | 
			
		||||
            {
 | 
			
		||||
                ret = this.RawExecuteInserted();
 | 
			
		||||
                ClearData();
 | 
			
		||||
                return ret;
 | 
			
		||||
            }
 | 
			
		||||
            if (_transaction != null)
 | 
			
		||||
            {
 | 
			
		||||
                for (var a = 0; a < ss.Length; a++)
 | 
			
		||||
                {
 | 
			
		||||
                    _source = ss[a];
 | 
			
		||||
                    ret.AddRange(this.RawExecuteInserted());
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                using (var conn = _orm.Ado.MasterPool.Get())
 | 
			
		||||
                {
 | 
			
		||||
                    _transaction = conn.Value.BeginTransaction();
 | 
			
		||||
                    try
 | 
			
		||||
                    {
 | 
			
		||||
                        for (var a = 0; a < ss.Length; a++)
 | 
			
		||||
                        {
 | 
			
		||||
                            _source = ss[a];
 | 
			
		||||
                            ret.AddRange(this.RawExecuteInserted());
 | 
			
		||||
                        }
 | 
			
		||||
                        _transaction.Commit();
 | 
			
		||||
                    }
 | 
			
		||||
                    catch
 | 
			
		||||
                    {
 | 
			
		||||
                        _transaction.Rollback();
 | 
			
		||||
                        throw;
 | 
			
		||||
                    }
 | 
			
		||||
                    _transaction = null;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            ClearData();
 | 
			
		||||
            return ret;
 | 
			
		||||
        }
 | 
			
		||||
        async protected Task<List<T1>> SplitExecuteInsertedAsync(int valuesLimit, int parameterLimit)
 | 
			
		||||
        {
 | 
			
		||||
            var ss = SplitSource(valuesLimit, parameterLimit);
 | 
			
		||||
            var ret = new List<T1>();
 | 
			
		||||
            if (ss.Any() == false)
 | 
			
		||||
            {
 | 
			
		||||
                ClearData();
 | 
			
		||||
                return ret;
 | 
			
		||||
            }
 | 
			
		||||
            if (ss.Length == 1)
 | 
			
		||||
            {
 | 
			
		||||
                ret = await this.RawExecuteInsertedAsync();
 | 
			
		||||
                ClearData();
 | 
			
		||||
                return ret;
 | 
			
		||||
            }
 | 
			
		||||
            if (_transaction != null)
 | 
			
		||||
            {
 | 
			
		||||
                for (var a = 0; a < ss.Length; a++)
 | 
			
		||||
                {
 | 
			
		||||
                    _source = ss[a];
 | 
			
		||||
                    ret.AddRange(await this.RawExecuteInsertedAsync());
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                using (var conn = await _orm.Ado.MasterPool.GetAsync())
 | 
			
		||||
                {
 | 
			
		||||
                    _transaction = conn.Value.BeginTransaction();
 | 
			
		||||
                    try
 | 
			
		||||
                    {
 | 
			
		||||
                        for (var a = 0; a < ss.Length; a++)
 | 
			
		||||
                        {
 | 
			
		||||
                            _source = ss[a];
 | 
			
		||||
                            ret.AddRange(await this.RawExecuteInsertedAsync());
 | 
			
		||||
                        }
 | 
			
		||||
                        _transaction.Commit();
 | 
			
		||||
                    }
 | 
			
		||||
                    catch
 | 
			
		||||
                    {
 | 
			
		||||
                        _transaction.Rollback();
 | 
			
		||||
                        throw;
 | 
			
		||||
                    }
 | 
			
		||||
                    _transaction = null;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            ClearData();
 | 
			
		||||
            return ret;
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
		protected int RawExecuteAffrows() {
 | 
			
		||||
			var sql = ToSql();
 | 
			
		||||
			var before = new Aop.CurdBeforeEventArgs(_table.Type, Aop.CurdType.Insert, sql, _params);
 | 
			
		||||
			_orm.Aop.CurdBefore?.Invoke(this, before);
 | 
			
		||||
			var affrows = 0;
 | 
			
		||||
			Exception exception = null;
 | 
			
		||||
			try {
 | 
			
		||||
				affrows = _orm.Ado.ExecuteNonQuery(_connection, _transaction, CommandType.Text, sql, _params);
 | 
			
		||||
			} catch (Exception ex) {
 | 
			
		||||
				exception = ex;
 | 
			
		||||
				throw ex;
 | 
			
		||||
			} finally {
 | 
			
		||||
				var after = new Aop.CurdAfterEventArgs(before, exception, affrows);
 | 
			
		||||
				_orm.Aop.CurdAfter?.Invoke(this, after);
 | 
			
		||||
			}
 | 
			
		||||
			this.ClearData();
 | 
			
		||||
			return affrows;
 | 
			
		||||
		}
 | 
			
		||||
		async protected Task<int> RawExecuteAffrowsAsync() {
 | 
			
		||||
			var sql = ToSql();
 | 
			
		||||
			var before = new Aop.CurdBeforeEventArgs(_table.Type, Aop.CurdType.Insert, sql, _params);
 | 
			
		||||
			_orm.Aop.CurdBefore?.Invoke(this, before);
 | 
			
		||||
			var affrows = 0;
 | 
			
		||||
			Exception exception = null;
 | 
			
		||||
			try {
 | 
			
		||||
				affrows = await _orm.Ado.ExecuteNonQueryAsync(_connection, _transaction, CommandType.Text, sql, _params);
 | 
			
		||||
			} catch (Exception ex) {
 | 
			
		||||
				exception = ex;
 | 
			
		||||
				throw ex;
 | 
			
		||||
			} finally {
 | 
			
		||||
				var after = new Aop.CurdAfterEventArgs(before, exception, affrows);
 | 
			
		||||
				_orm.Aop.CurdAfter?.Invoke(this, after);
 | 
			
		||||
			}
 | 
			
		||||
			this.ClearData();
 | 
			
		||||
			return affrows;
 | 
			
		||||
		}
 | 
			
		||||
		protected abstract long RawExecuteIdentity();
 | 
			
		||||
		protected abstract Task<long> RawExecuteIdentityAsync();
 | 
			
		||||
		protected abstract List<T1> RawExecuteInserted();
 | 
			
		||||
		protected abstract Task<List<T1>> RawExecuteInsertedAsync();
 | 
			
		||||
        protected int RawExecuteAffrows()
 | 
			
		||||
        {
 | 
			
		||||
            var sql = ToSql();
 | 
			
		||||
            var before = new Aop.CurdBeforeEventArgs(_table.Type, Aop.CurdType.Insert, sql, _params);
 | 
			
		||||
            _orm.Aop.CurdBefore?.Invoke(this, before);
 | 
			
		||||
            var affrows = 0;
 | 
			
		||||
            Exception exception = null;
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                affrows = _orm.Ado.ExecuteNonQuery(_connection, _transaction, CommandType.Text, sql, _params);
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
                exception = ex;
 | 
			
		||||
                throw ex;
 | 
			
		||||
            }
 | 
			
		||||
            finally
 | 
			
		||||
            {
 | 
			
		||||
                var after = new Aop.CurdAfterEventArgs(before, exception, affrows);
 | 
			
		||||
                _orm.Aop.CurdAfter?.Invoke(this, after);
 | 
			
		||||
            }
 | 
			
		||||
            this.ClearData();
 | 
			
		||||
            return affrows;
 | 
			
		||||
        }
 | 
			
		||||
        async protected Task<int> RawExecuteAffrowsAsync()
 | 
			
		||||
        {
 | 
			
		||||
            var sql = ToSql();
 | 
			
		||||
            var before = new Aop.CurdBeforeEventArgs(_table.Type, Aop.CurdType.Insert, sql, _params);
 | 
			
		||||
            _orm.Aop.CurdBefore?.Invoke(this, before);
 | 
			
		||||
            var affrows = 0;
 | 
			
		||||
            Exception exception = null;
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                affrows = await _orm.Ado.ExecuteNonQueryAsync(_connection, _transaction, CommandType.Text, sql, _params);
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
                exception = ex;
 | 
			
		||||
                throw ex;
 | 
			
		||||
            }
 | 
			
		||||
            finally
 | 
			
		||||
            {
 | 
			
		||||
                var after = new Aop.CurdAfterEventArgs(before, exception, affrows);
 | 
			
		||||
                _orm.Aop.CurdAfter?.Invoke(this, after);
 | 
			
		||||
            }
 | 
			
		||||
            this.ClearData();
 | 
			
		||||
            return affrows;
 | 
			
		||||
        }
 | 
			
		||||
        protected abstract long RawExecuteIdentity();
 | 
			
		||||
        protected abstract Task<long> RawExecuteIdentityAsync();
 | 
			
		||||
        protected abstract List<T1> RawExecuteInserted();
 | 
			
		||||
        protected abstract Task<List<T1>> RawExecuteInsertedAsync();
 | 
			
		||||
 | 
			
		||||
		public abstract int ExecuteAffrows();
 | 
			
		||||
		public abstract Task<int> ExecuteAffrowsAsync();
 | 
			
		||||
		public abstract long ExecuteIdentity();
 | 
			
		||||
		public abstract Task<long> ExecuteIdentityAsync();
 | 
			
		||||
		public abstract List<T1> ExecuteInserted();
 | 
			
		||||
		public abstract Task<List<T1>> ExecuteInsertedAsync();
 | 
			
		||||
        public abstract int ExecuteAffrows();
 | 
			
		||||
        public abstract Task<int> ExecuteAffrowsAsync();
 | 
			
		||||
        public abstract long ExecuteIdentity();
 | 
			
		||||
        public abstract Task<long> ExecuteIdentityAsync();
 | 
			
		||||
        public abstract List<T1> ExecuteInserted();
 | 
			
		||||
        public abstract Task<List<T1>> ExecuteInsertedAsync();
 | 
			
		||||
 | 
			
		||||
		public IInsert<T1> IgnoreColumns(Expression<Func<T1, object>> columns) {
 | 
			
		||||
			var cols = _commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, columns?.Body, false, null).Distinct();
 | 
			
		||||
			_ignore.Clear();
 | 
			
		||||
			foreach (var col in cols) _ignore.Add(col, true);
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
		public IInsert<T1> InsertColumns(Expression<Func<T1, object>> columns) {
 | 
			
		||||
			var cols = _commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, columns?.Body, false, null).ToDictionary(a => a, a => true);
 | 
			
		||||
			_ignore.Clear();
 | 
			
		||||
			foreach (var col in _table.Columns.Values)
 | 
			
		||||
				if (cols.ContainsKey(col.Attribute.Name) == false)
 | 
			
		||||
					_ignore.Add(col.Attribute.Name, true);
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
        public IInsert<T1> IgnoreColumns(Expression<Func<T1, object>> columns)
 | 
			
		||||
        {
 | 
			
		||||
            var cols = _commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, columns?.Body, false, null).Distinct();
 | 
			
		||||
            _ignore.Clear();
 | 
			
		||||
            foreach (var col in cols) _ignore.Add(col, true);
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
        public IInsert<T1> InsertColumns(Expression<Func<T1, object>> columns)
 | 
			
		||||
        {
 | 
			
		||||
            var cols = _commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, columns?.Body, false, null).ToDictionary(a => a, a => true);
 | 
			
		||||
            _ignore.Clear();
 | 
			
		||||
            foreach (var col in _table.Columns.Values)
 | 
			
		||||
                if (cols.ContainsKey(col.Attribute.Name) == false)
 | 
			
		||||
                    _ignore.Add(col.Attribute.Name, true);
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		public IInsert<T1> AsTable(Func<string, string> tableRule) {
 | 
			
		||||
			_tableRule = tableRule;
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
		public IInsert<T1> AsType(Type entityType) {
 | 
			
		||||
			if (entityType == typeof(object)) throw new Exception("IInsert.AsType 参数不支持指定为 object");
 | 
			
		||||
			if (entityType == _table.Type) return this;
 | 
			
		||||
			var newtb = _commonUtils.GetTableByEntity(entityType);
 | 
			
		||||
			_table = newtb ?? throw new Exception("IInsert.AsType 参数错误,请传入正确的实体类型");
 | 
			
		||||
			if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(entityType);
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
        public IInsert<T1> AsTable(Func<string, string> tableRule)
 | 
			
		||||
        {
 | 
			
		||||
            _tableRule = tableRule;
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
        public IInsert<T1> AsType(Type entityType)
 | 
			
		||||
        {
 | 
			
		||||
            if (entityType == typeof(object)) throw new Exception("IInsert.AsType 参数不支持指定为 object");
 | 
			
		||||
            if (entityType == _table.Type) return this;
 | 
			
		||||
            var newtb = _commonUtils.GetTableByEntity(entityType);
 | 
			
		||||
            _table = newtb ?? throw new Exception("IInsert.AsType 参数错误,请传入正确的实体类型");
 | 
			
		||||
            if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(entityType);
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		public virtual string ToSql() {
 | 
			
		||||
			if (_source == null || _source.Any() == false) return null;
 | 
			
		||||
			var sb = new StringBuilder();
 | 
			
		||||
			sb.Append("INSERT INTO ").Append(_commonUtils.QuoteSqlName(_tableRule?.Invoke(_table.DbName) ?? _table.DbName)).Append("(");
 | 
			
		||||
			var colidx = 0;
 | 
			
		||||
			foreach (var col in _table.Columns.Values)
 | 
			
		||||
				if (col.Attribute.IsIdentity == false && _ignore.ContainsKey(col.Attribute.Name) == false) {
 | 
			
		||||
					if (colidx > 0) sb.Append(", ");
 | 
			
		||||
					sb.Append(_commonUtils.QuoteSqlName(col.Attribute.Name));
 | 
			
		||||
					++colidx;
 | 
			
		||||
				}
 | 
			
		||||
			sb.Append(") VALUES");
 | 
			
		||||
			_params = _noneParameter ? new DbParameter[0] : new DbParameter[colidx * _source.Count];
 | 
			
		||||
			var specialParams = new List<DbParameter>();
 | 
			
		||||
			var didx = 0;
 | 
			
		||||
			foreach (var d in _source) {
 | 
			
		||||
				if (didx > 0) sb.Append(", ");
 | 
			
		||||
				sb.Append("(");
 | 
			
		||||
				var colidx2 = 0;
 | 
			
		||||
				foreach (var col in _table.Columns.Values)
 | 
			
		||||
					if (col.Attribute.IsIdentity == false && _ignore.ContainsKey(col.Attribute.Name) == false) {
 | 
			
		||||
						if (colidx2 > 0) sb.Append(", ");
 | 
			
		||||
						object val = col.GetMapValue(d);
 | 
			
		||||
						if (col.Attribute.IsPrimary && col.Attribute.MapType.NullableTypeOrThis() == typeof(Guid) && (val == null || (Guid)val == Guid.Empty))
 | 
			
		||||
							col.SetMapValue(d, val = FreeUtil.NewMongodbId());
 | 
			
		||||
						if (_noneParameter)
 | 
			
		||||
							sb.Append(_commonUtils.GetNoneParamaterSqlValue(specialParams, col.Attribute.MapType, val));
 | 
			
		||||
						else {
 | 
			
		||||
							sb.Append(_commonUtils.QuoteWriteParamter(col.Attribute.MapType, _commonUtils.QuoteParamterName($"{col.CsName}_{didx}")));
 | 
			
		||||
							_params[didx * colidx + colidx2] = _commonUtils.AppendParamter(null, $"{col.CsName}_{didx}", col.Attribute.MapType, val);
 | 
			
		||||
						}
 | 
			
		||||
						++colidx2;
 | 
			
		||||
					}
 | 
			
		||||
				sb.Append(")");
 | 
			
		||||
				++didx;
 | 
			
		||||
			}
 | 
			
		||||
			if (_noneParameter && specialParams.Any())
 | 
			
		||||
				_params = specialParams.ToArray();
 | 
			
		||||
			return sb.ToString();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
        public virtual string ToSql()
 | 
			
		||||
        {
 | 
			
		||||
            if (_source == null || _source.Any() == false) return null;
 | 
			
		||||
            var sb = new StringBuilder();
 | 
			
		||||
            sb.Append("INSERT INTO ").Append(_commonUtils.QuoteSqlName(_tableRule?.Invoke(_table.DbName) ?? _table.DbName)).Append("(");
 | 
			
		||||
            var colidx = 0;
 | 
			
		||||
            foreach (var col in _table.Columns.Values)
 | 
			
		||||
                if (col.Attribute.IsIdentity == false && _ignore.ContainsKey(col.Attribute.Name) == false)
 | 
			
		||||
                {
 | 
			
		||||
                    if (colidx > 0) sb.Append(", ");
 | 
			
		||||
                    sb.Append(_commonUtils.QuoteSqlName(col.Attribute.Name));
 | 
			
		||||
                    ++colidx;
 | 
			
		||||
                }
 | 
			
		||||
            sb.Append(") VALUES");
 | 
			
		||||
            _params = _noneParameter ? new DbParameter[0] : new DbParameter[colidx * _source.Count];
 | 
			
		||||
            var specialParams = new List<DbParameter>();
 | 
			
		||||
            var didx = 0;
 | 
			
		||||
            foreach (var d in _source)
 | 
			
		||||
            {
 | 
			
		||||
                if (didx > 0) sb.Append(", ");
 | 
			
		||||
                sb.Append("(");
 | 
			
		||||
                var colidx2 = 0;
 | 
			
		||||
                foreach (var col in _table.Columns.Values)
 | 
			
		||||
                    if (col.Attribute.IsIdentity == false && _ignore.ContainsKey(col.Attribute.Name) == false)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (colidx2 > 0) sb.Append(", ");
 | 
			
		||||
                        object val = col.GetMapValue(d);
 | 
			
		||||
                        if (col.Attribute.IsPrimary && col.Attribute.MapType.NullableTypeOrThis() == typeof(Guid) && (val == null || (Guid)val == Guid.Empty))
 | 
			
		||||
                            col.SetMapValue(d, val = FreeUtil.NewMongodbId());
 | 
			
		||||
                        if (_noneParameter)
 | 
			
		||||
                            sb.Append(_commonUtils.GetNoneParamaterSqlValue(specialParams, col.Attribute.MapType, val));
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            sb.Append(_commonUtils.QuoteWriteParamter(col.Attribute.MapType, _commonUtils.QuoteParamterName($"{col.CsName}_{didx}")));
 | 
			
		||||
                            _params[didx * colidx + colidx2] = _commonUtils.AppendParamter(null, $"{col.CsName}_{didx}", col.Attribute.MapType, val);
 | 
			
		||||
                        }
 | 
			
		||||
                        ++colidx2;
 | 
			
		||||
                    }
 | 
			
		||||
                sb.Append(")");
 | 
			
		||||
                ++didx;
 | 
			
		||||
            }
 | 
			
		||||
            if (_noneParameter && specialParams.Any())
 | 
			
		||||
                _params = specialParams.ToArray();
 | 
			
		||||
            return sb.ToString();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -5,178 +5,204 @@ using System.Data;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider {
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	public abstract class Select10Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> : Select0Provider<ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, T1>, ISelect<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 abstract class Select10Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> : Select0Provider<ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, T1>, ISelect<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 Select10Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) {
 | 
			
		||||
			if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10));
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T4)), Alias = $"SP10d", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T5)), Alias = $"SP10e", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T6)), Alias = $"SP10f", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T7)), Alias = $"SP10g", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T8)), Alias = $"SP10h", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T9)), Alias = $"SP10i", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T10)), Alias = $"SP10j", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
		}
 | 
			
		||||
        public Select10Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere)
 | 
			
		||||
        {
 | 
			
		||||
            if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10));
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T4)), Alias = $"SP10d", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T5)), Alias = $"SP10e", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T6)), Alias = $"SP10f", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T7)), Alias = $"SP10g", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T8)), Alias = $"SP10h", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T9)), Alias = $"SP10i", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T10)), Alias = $"SP10j", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.Avg<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalAvg<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.Avg<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalAvg<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.AvgAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalAvgAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.AvgAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalAvgAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelectGrouping<TKey, (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.GroupBy<TKey>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TKey>> exp) {
 | 
			
		||||
			if (exp == null) return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)>(exp?.Body);
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> (exp?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelectGrouping<TKey, (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.GroupBy<TKey>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TKey>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)>(exp?.Body);
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)>(exp?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.Max<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMax<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.Max<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMax<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.MaxAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMaxAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.MaxAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMaxAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.Min<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMin<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.Min<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMin<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.MinAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMinAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.MinAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMinAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.OrderBy<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalOrderBy(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.OrderBy<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalOrderBy(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.OrderByDescending<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalOrderByDescending(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.OrderByDescending<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalOrderByDescending(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.Sum<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalSum<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.Sum<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalSum<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.SumAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalSumAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.SumAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalSumAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TReturn ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.ToAggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, ISelectGroupingAggregate<T6>, ISelectGroupingAggregate<T7>, ISelectGroupingAggregate<T8>, ISelectGroupingAggregate<T9>, ISelectGroupingAggregate<T10>, TReturn>> select) {
 | 
			
		||||
			if (select == null) return default(TReturn);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToAggregate<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TReturn ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.ToAggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, ISelectGroupingAggregate<T6>, ISelectGroupingAggregate<T7>, ISelectGroupingAggregate<T8>, ISelectGroupingAggregate<T9>, ISelectGroupingAggregate<T10>, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return default(TReturn);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToAggregate<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TReturn> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.ToAggregateAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, ISelectGroupingAggregate<T6>, ISelectGroupingAggregate<T7>, ISelectGroupingAggregate<T8>, ISelectGroupingAggregate<T9>, ISelectGroupingAggregate<T10>, TReturn>> select) {
 | 
			
		||||
			if (select == null) return Task.FromResult(default(TReturn));
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToAggregateAsync<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TReturn> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.ToAggregateAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, ISelectGroupingAggregate<T6>, ISelectGroupingAggregate<T7>, ISelectGroupingAggregate<T8>, ISelectGroupingAggregate<T9>, ISelectGroupingAggregate<T10>, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return Task.FromResult(default(TReturn));
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToAggregateAsync<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		List<TReturn> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.ToList<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
		Task<List<TReturn>> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.ToListAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
		List<TDto> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.ToList<TDto>() => (this as ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>).ToList(GetToListDtoSelector<TDto>());
 | 
			
		||||
		Task<List<TDto>> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.ToListAsync<TDto>() => (this as ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>).ToListAsync(GetToListDtoSelector<TDto>());
 | 
			
		||||
		Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TDto>> GetToListDtoSelector<TDto>() {
 | 
			
		||||
			var ctor = typeof(TDto).GetConstructor(new Type[0]);
 | 
			
		||||
			return Expression.Lambda<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TDto>>(Expression.New(ctor),
 | 
			
		||||
				_tables[0].Parameter ?? Expression.Parameter(typeof(T1), "a"),
 | 
			
		||||
				Expression.Parameter(typeof(T2), "b"),
 | 
			
		||||
				Expression.Parameter(typeof(T3), "c"),
 | 
			
		||||
				Expression.Parameter(typeof(T4), "d"),
 | 
			
		||||
				Expression.Parameter(typeof(T5), "e"),
 | 
			
		||||
				Expression.Parameter(typeof(T6), "f"),
 | 
			
		||||
				Expression.Parameter(typeof(T7), "g"),
 | 
			
		||||
				Expression.Parameter(typeof(T8), "h"),
 | 
			
		||||
				Expression.Parameter(typeof(T9), "i"),
 | 
			
		||||
				Expression.Parameter(typeof(T10), "j"));
 | 
			
		||||
		}
 | 
			
		||||
        List<TReturn> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.ToList<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
        Task<List<TReturn>> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.ToListAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
        List<TDto> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.ToList<TDto>() => (this as ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>).ToList(GetToListDtoSelector<TDto>());
 | 
			
		||||
        Task<List<TDto>> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.ToListAsync<TDto>() => (this as ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>).ToListAsync(GetToListDtoSelector<TDto>());
 | 
			
		||||
        Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TDto>> GetToListDtoSelector<TDto>()
 | 
			
		||||
        {
 | 
			
		||||
            var ctor = typeof(TDto).GetConstructor(new Type[0]);
 | 
			
		||||
            return Expression.Lambda<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TDto>>(Expression.New(ctor),
 | 
			
		||||
                _tables[0].Parameter ?? Expression.Parameter(typeof(T1), "a"),
 | 
			
		||||
                Expression.Parameter(typeof(T2), "b"),
 | 
			
		||||
                Expression.Parameter(typeof(T3), "c"),
 | 
			
		||||
                Expression.Parameter(typeof(T4), "d"),
 | 
			
		||||
                Expression.Parameter(typeof(T5), "e"),
 | 
			
		||||
                Expression.Parameter(typeof(T6), "f"),
 | 
			
		||||
                Expression.Parameter(typeof(T7), "g"),
 | 
			
		||||
                Expression.Parameter(typeof(T8), "h"),
 | 
			
		||||
                Expression.Parameter(typeof(T9), "i"),
 | 
			
		||||
                Expression.Parameter(typeof(T10), "j"));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		DataTable ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.ToDataTable<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToDataTable(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToDataTable(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        DataTable ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.ToDataTable<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToDataTable(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToDataTable(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<DataTable> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.ToDataTableAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<DataTable> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.ToDataTableAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		string ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.ToSql<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        string ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.ToSql<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.Where(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.Where(null);
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.Where(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.Where(null);
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> exp) {
 | 
			
		||||
			if (condition == false || exp == null) return this.Where(null);
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this;
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (condition == false || exp == null) return this.Where(null);
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		bool ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.Any();
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any();
 | 
			
		||||
		}
 | 
			
		||||
        bool ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.Any();
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<bool> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.AnyAsync(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.AnyAsync();
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
        Task<bool> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.AnyAsync(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.AnyAsync();
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -5,154 +5,180 @@ using System.Data;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider {
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	public abstract class Select2Provider<T1, T2> : Select0Provider<ISelect<T1, T2>, T1>, ISelect<T1, T2>
 | 
			
		||||
			where T1 : class
 | 
			
		||||
			where T2 : class {
 | 
			
		||||
    public abstract class Select2Provider<T1, T2> : Select0Provider<ISelect<T1, T2>, T1>, ISelect<T1, T2>
 | 
			
		||||
            where T1 : class
 | 
			
		||||
            where T2 : class
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
		public Select2Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) {
 | 
			
		||||
			if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2));
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
		}
 | 
			
		||||
        public Select2Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere)
 | 
			
		||||
        {
 | 
			
		||||
            if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2));
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2>.Avg<TMember>(Expression<Func<T1, T2, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalAvg<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2>.Avg<TMember>(Expression<Func<T1, T2, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalAvg<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2>.AvgAsync<TMember>(Expression<Func<T1, T2, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalAvgAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2>.AvgAsync<TMember>(Expression<Func<T1, T2, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalAvgAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelectGrouping<TKey, (T1, T2)> ISelect<T1, T2>.GroupBy<TKey>(Expression<Func<T1, T2, TKey>> exp) {
 | 
			
		||||
			if (exp == null) return this.InternalGroupBy<TKey, (T1, T2)>(exp?.Body);
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.InternalGroupBy<TKey, (T1, T2)>(exp?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelectGrouping<TKey, (T1, T2)> ISelect<T1, T2>.GroupBy<TKey>(Expression<Func<T1, T2, TKey>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.InternalGroupBy<TKey, (T1, T2)>(exp?.Body);
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.InternalGroupBy<TKey, (T1, T2)>(exp?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2>.Max<TMember>(Expression<Func<T1, T2, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMax<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2>.Max<TMember>(Expression<Func<T1, T2, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMax<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2>.MaxAsync<TMember>(Expression<Func<T1, T2, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMaxAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2>.MaxAsync<TMember>(Expression<Func<T1, T2, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMaxAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2>.Min<TMember>(Expression<Func<T1, T2, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMin<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2>.Min<TMember>(Expression<Func<T1, T2, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMin<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2>.MinAsync<TMember>(Expression<Func<T1, T2, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMinAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2>.MinAsync<TMember>(Expression<Func<T1, T2, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMinAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2> ISelect<T1, T2>.OrderBy<TMember>(Expression<Func<T1, T2, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalOrderBy(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2> ISelect<T1, T2>.OrderBy<TMember>(Expression<Func<T1, T2, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalOrderBy(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2> ISelect<T1, T2>.OrderByDescending<TMember>(Expression<Func<T1, T2, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalOrderByDescending(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2> ISelect<T1, T2>.OrderByDescending<TMember>(Expression<Func<T1, T2, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalOrderByDescending(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2>.Sum<TMember>(Expression<Func<T1, T2, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalSum<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2>.Sum<TMember>(Expression<Func<T1, T2, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalSum<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2>.SumAsync<TMember>(Expression<Func<T1, T2, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalSumAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2>.SumAsync<TMember>(Expression<Func<T1, T2, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalSumAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TReturn ISelect<T1, T2>.ToAggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, TReturn>> select) {
 | 
			
		||||
			if (select == null) return default(TReturn);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToAggregate<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TReturn ISelect<T1, T2>.ToAggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return default(TReturn);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToAggregate<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TReturn> ISelect<T1, T2>.ToAggregateAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, TReturn>> select) {
 | 
			
		||||
			if (select == null) return Task.FromResult(default(TReturn));
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToAggregateAsync<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TReturn> ISelect<T1, T2>.ToAggregateAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return Task.FromResult(default(TReturn));
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToAggregateAsync<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		List<TReturn> ISelect<T1, T2>.ToList<TReturn>(Expression<Func<T1, T2, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
		Task<List<TReturn>> ISelect<T1, T2>.ToListAsync<TReturn>(Expression<Func<T1, T2, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
		List<TDto> ISelect<T1, T2>.ToList<TDto>() => (this as ISelect<T1, T2>).ToList(GetToListDtoSelector<TDto>());
 | 
			
		||||
		Task<List<TDto>> ISelect<T1, T2>.ToListAsync<TDto>() => (this as ISelect<T1, T2>).ToListAsync(GetToListDtoSelector<TDto>());
 | 
			
		||||
		Expression<Func<T1, T2, TDto>> GetToListDtoSelector<TDto>() {
 | 
			
		||||
			var ctor = typeof(TDto).GetConstructor(new Type[0]);
 | 
			
		||||
			return Expression.Lambda<Func<T1, T2, TDto>>(Expression.New(ctor),
 | 
			
		||||
				_tables[0].Parameter ?? Expression.Parameter(typeof(T1), "a"),
 | 
			
		||||
				Expression.Parameter(typeof(T2), "b"));
 | 
			
		||||
		}
 | 
			
		||||
        List<TReturn> ISelect<T1, T2>.ToList<TReturn>(Expression<Func<T1, T2, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
        Task<List<TReturn>> ISelect<T1, T2>.ToListAsync<TReturn>(Expression<Func<T1, T2, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
        List<TDto> ISelect<T1, T2>.ToList<TDto>() => (this as ISelect<T1, T2>).ToList(GetToListDtoSelector<TDto>());
 | 
			
		||||
        Task<List<TDto>> ISelect<T1, T2>.ToListAsync<TDto>() => (this as ISelect<T1, T2>).ToListAsync(GetToListDtoSelector<TDto>());
 | 
			
		||||
        Expression<Func<T1, T2, TDto>> GetToListDtoSelector<TDto>()
 | 
			
		||||
        {
 | 
			
		||||
            var ctor = typeof(TDto).GetConstructor(new Type[0]);
 | 
			
		||||
            return Expression.Lambda<Func<T1, T2, TDto>>(Expression.New(ctor),
 | 
			
		||||
                _tables[0].Parameter ?? Expression.Parameter(typeof(T1), "a"),
 | 
			
		||||
                Expression.Parameter(typeof(T2), "b"));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		DataTable ISelect<T1, T2>.ToDataTable<TReturn>(Expression<Func<T1, T2, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToDataTable(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToDataTable(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        DataTable ISelect<T1, T2>.ToDataTable<TReturn>(Expression<Func<T1, T2, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToDataTable(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToDataTable(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<DataTable> ISelect<T1, T2>.ToDataTableAsync<TReturn>(Expression<Func<T1, T2, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<DataTable> ISelect<T1, T2>.ToDataTableAsync<TReturn>(Expression<Func<T1, T2, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		string ISelect<T1, T2>.ToSql<TReturn>(Expression<Func<T1, T2, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        string ISelect<T1, T2>.ToSql<TReturn>(Expression<Func<T1, T2, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2> ISelect<T1, T2>.Where(Expression<Func<T1, T2, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.Where(null);
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2> ISelect<T1, T2>.Where(Expression<Func<T1, T2, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.Where(null);
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2> ISelect<T1, T2>.WhereIf(bool condition, Expression<Func<T1, T2, bool>> exp) {
 | 
			
		||||
			if (condition == false || exp == null) return this;
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2> ISelect<T1, T2>.WhereIf(bool condition, Expression<Func<T1, T2, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (condition == false || exp == null) return this;
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		bool ISelect<T1, T2>.Any(Expression<Func<T1, T2, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.Any();
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any();
 | 
			
		||||
		}
 | 
			
		||||
        bool ISelect<T1, T2>.Any(Expression<Func<T1, T2, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.Any();
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<bool> ISelect<T1, T2>.AnyAsync(Expression<Func<T1, T2, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.AnyAsync();
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
        Task<bool> ISelect<T1, T2>.AnyAsync(Expression<Func<T1, T2, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.AnyAsync();
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -5,157 +5,183 @@ using System.Data;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider {
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	public abstract class Select3Provider<T1, T2, T3> : Select0Provider<ISelect<T1, T2, T3>, T1>, ISelect<T1, T2, T3>
 | 
			
		||||
			where T1 : class
 | 
			
		||||
			where T2 : class
 | 
			
		||||
			where T3 : class {
 | 
			
		||||
    public abstract class Select3Provider<T1, T2, T3> : Select0Provider<ISelect<T1, T2, T3>, T1>, ISelect<T1, T2, T3>
 | 
			
		||||
            where T1 : class
 | 
			
		||||
            where T2 : class
 | 
			
		||||
            where T3 : class
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
		public Select3Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) {
 | 
			
		||||
			if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3));
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
		}
 | 
			
		||||
        public Select3Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere)
 | 
			
		||||
        {
 | 
			
		||||
            if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3));
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3>.Avg<TMember>(Expression<Func<T1, T2, T3, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalAvg<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3>.Avg<TMember>(Expression<Func<T1, T2, T3, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalAvg<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3>.AvgAsync<TMember>(Expression<Func<T1, T2, T3, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalAvgAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3>.AvgAsync<TMember>(Expression<Func<T1, T2, T3, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalAvgAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelectGrouping<TKey, (T1, T2, T3)> ISelect<T1, T2, T3>.GroupBy<TKey>(Expression<Func<T1, T2, T3, TKey>> exp) {
 | 
			
		||||
			if (exp == null) return this.InternalGroupBy<TKey, (T1, T2, T3)>(exp?.Body);
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.InternalGroupBy<TKey, (T1, T2, T3)>(exp?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelectGrouping<TKey, (T1, T2, T3)> ISelect<T1, T2, T3>.GroupBy<TKey>(Expression<Func<T1, T2, T3, TKey>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.InternalGroupBy<TKey, (T1, T2, T3)>(exp?.Body);
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.InternalGroupBy<TKey, (T1, T2, T3)>(exp?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3>.Max<TMember>(Expression<Func<T1, T2, T3, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMax<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3>.Max<TMember>(Expression<Func<T1, T2, T3, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMax<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3>.MaxAsync<TMember>(Expression<Func<T1, T2, T3, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMaxAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3>.MaxAsync<TMember>(Expression<Func<T1, T2, T3, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMaxAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3>.Min<TMember>(Expression<Func<T1, T2, T3, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMin<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3>.Min<TMember>(Expression<Func<T1, T2, T3, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMin<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3>.MinAsync<TMember>(Expression<Func<T1, T2, T3, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMinAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3>.MinAsync<TMember>(Expression<Func<T1, T2, T3, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMinAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3> ISelect<T1, T2, T3>.OrderBy<TMember>(Expression<Func<T1, T2, T3, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalOrderBy(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3> ISelect<T1, T2, T3>.OrderBy<TMember>(Expression<Func<T1, T2, T3, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalOrderBy(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3> ISelect<T1, T2, T3>.OrderByDescending<TMember>(Expression<Func<T1, T2, T3, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalOrderByDescending(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3> ISelect<T1, T2, T3>.OrderByDescending<TMember>(Expression<Func<T1, T2, T3, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalOrderByDescending(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3>.Sum<TMember>(Expression<Func<T1, T2, T3, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalSum<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3>.Sum<TMember>(Expression<Func<T1, T2, T3, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalSum<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3>.SumAsync<TMember>(Expression<Func<T1, T2, T3, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalSumAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3>.SumAsync<TMember>(Expression<Func<T1, T2, T3, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalSumAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TReturn ISelect<T1, T2, T3>.ToAggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, TReturn>> select) {
 | 
			
		||||
			if (select == null) return default(TReturn);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToAggregate<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TReturn ISelect<T1, T2, T3>.ToAggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return default(TReturn);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToAggregate<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TReturn> ISelect<T1, T2, T3>.ToAggregateAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, TReturn>> select) {
 | 
			
		||||
			if (select == null) return Task.FromResult(default(TReturn));
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToAggregateAsync<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TReturn> ISelect<T1, T2, T3>.ToAggregateAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return Task.FromResult(default(TReturn));
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToAggregateAsync<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		List<TReturn> ISelect<T1, T2, T3>.ToList<TReturn>(Expression<Func<T1, T2, T3, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
		Task<List<TReturn>> ISelect<T1, T2, T3>.ToListAsync<TReturn>(Expression<Func<T1, T2, T3, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
		List<TDto> ISelect<T1, T2, T3>.ToList<TDto>() => (this as ISelect<T1, T2, T3>).ToList(GetToListDtoSelector<TDto>());
 | 
			
		||||
		Task<List<TDto>> ISelect<T1, T2, T3>.ToListAsync<TDto>() => (this as ISelect<T1, T2, T3>).ToListAsync(GetToListDtoSelector<TDto>());
 | 
			
		||||
		Expression<Func<T1, T2, T3, TDto>> GetToListDtoSelector<TDto>() {
 | 
			
		||||
			var ctor = typeof(TDto).GetConstructor(new Type[0]);
 | 
			
		||||
			return Expression.Lambda<Func<T1, T2, T3, TDto>>(Expression.New(ctor),
 | 
			
		||||
				_tables[0].Parameter ?? Expression.Parameter(typeof(T1), "a"),
 | 
			
		||||
				Expression.Parameter(typeof(T2), "b"),
 | 
			
		||||
				Expression.Parameter(typeof(T3), "c"));
 | 
			
		||||
		}
 | 
			
		||||
        List<TReturn> ISelect<T1, T2, T3>.ToList<TReturn>(Expression<Func<T1, T2, T3, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
        Task<List<TReturn>> ISelect<T1, T2, T3>.ToListAsync<TReturn>(Expression<Func<T1, T2, T3, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
        List<TDto> ISelect<T1, T2, T3>.ToList<TDto>() => (this as ISelect<T1, T2, T3>).ToList(GetToListDtoSelector<TDto>());
 | 
			
		||||
        Task<List<TDto>> ISelect<T1, T2, T3>.ToListAsync<TDto>() => (this as ISelect<T1, T2, T3>).ToListAsync(GetToListDtoSelector<TDto>());
 | 
			
		||||
        Expression<Func<T1, T2, T3, TDto>> GetToListDtoSelector<TDto>()
 | 
			
		||||
        {
 | 
			
		||||
            var ctor = typeof(TDto).GetConstructor(new Type[0]);
 | 
			
		||||
            return Expression.Lambda<Func<T1, T2, T3, TDto>>(Expression.New(ctor),
 | 
			
		||||
                _tables[0].Parameter ?? Expression.Parameter(typeof(T1), "a"),
 | 
			
		||||
                Expression.Parameter(typeof(T2), "b"),
 | 
			
		||||
                Expression.Parameter(typeof(T3), "c"));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		DataTable ISelect<T1, T2, T3>.ToDataTable<TReturn>(Expression<Func<T1, T2, T3, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToDataTable(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToDataTable(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        DataTable ISelect<T1, T2, T3>.ToDataTable<TReturn>(Expression<Func<T1, T2, T3, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToDataTable(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToDataTable(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<DataTable> ISelect<T1, T2, T3>.ToDataTableAsync<TReturn>(Expression<Func<T1, T2, T3, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<DataTable> ISelect<T1, T2, T3>.ToDataTableAsync<TReturn>(Expression<Func<T1, T2, T3, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		string ISelect<T1, T2, T3>.ToSql<TReturn>(Expression<Func<T1, T2, T3, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        string ISelect<T1, T2, T3>.ToSql<TReturn>(Expression<Func<T1, T2, T3, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3> ISelect<T1, T2, T3>.Where(Expression<Func<T1, T2, T3, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.Where(null);
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3> ISelect<T1, T2, T3>.Where(Expression<Func<T1, T2, T3, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.Where(null);
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3> ISelect<T1, T2, T3>.WhereIf(bool condition, Expression<Func<T1, T2, T3, bool>> exp) {
 | 
			
		||||
			if (condition == false || exp == null) return this;
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3> ISelect<T1, T2, T3>.WhereIf(bool condition, Expression<Func<T1, T2, T3, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (condition == false || exp == null) return this;
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		bool ISelect<T1, T2, T3>.Any(Expression<Func<T1, T2, T3, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.Any();
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any();
 | 
			
		||||
		}
 | 
			
		||||
        bool ISelect<T1, T2, T3>.Any(Expression<Func<T1, T2, T3, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.Any();
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<bool> ISelect<T1, T2, T3>.AnyAsync(Expression<Func<T1, T2, T3, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.AnyAsync();
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
        Task<bool> ISelect<T1, T2, T3>.AnyAsync(Expression<Func<T1, T2, T3, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.AnyAsync();
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -5,160 +5,186 @@ using System.Data;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider {
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	public abstract class Select4Provider<T1, T2, T3, T4> : Select0Provider<ISelect<T1, T2, T3, T4>, T1>, ISelect<T1, T2, T3, T4>
 | 
			
		||||
			where T1 : class
 | 
			
		||||
			where T2 : class
 | 
			
		||||
			where T3 : class
 | 
			
		||||
			where T4 : class {
 | 
			
		||||
    public abstract class Select4Provider<T1, T2, T3, T4> : Select0Provider<ISelect<T1, T2, T3, T4>, T1>, ISelect<T1, T2, T3, T4>
 | 
			
		||||
            where T1 : class
 | 
			
		||||
            where T2 : class
 | 
			
		||||
            where T3 : class
 | 
			
		||||
            where T4 : class
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
		public Select4Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) {
 | 
			
		||||
			if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3), typeof(T4));
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T4)), Alias = $"SP10d", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
		}
 | 
			
		||||
        public Select4Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere)
 | 
			
		||||
        {
 | 
			
		||||
            if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3), typeof(T4));
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T4)), Alias = $"SP10d", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4>.Avg<TMember>(Expression<Func<T1, T2, T3, T4, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalAvg<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4>.Avg<TMember>(Expression<Func<T1, T2, T3, T4, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalAvg<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4>.AvgAsync<TMember>(Expression<Func<T1, T2, T3, T4, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalAvgAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4>.AvgAsync<TMember>(Expression<Func<T1, T2, T3, T4, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalAvgAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelectGrouping<TKey, (T1, T2, T3, T4)> ISelect<T1, T2, T3, T4>.GroupBy<TKey>(Expression<Func<T1, T2, T3, T4, TKey>> exp) {
 | 
			
		||||
			if (exp == null) return this.InternalGroupBy<TKey, (T1, T2, T3, T4)>(exp?.Body);
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.InternalGroupBy<TKey, (T1, T2, T3, T4)>(exp?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelectGrouping<TKey, (T1, T2, T3, T4)> ISelect<T1, T2, T3, T4>.GroupBy<TKey>(Expression<Func<T1, T2, T3, T4, TKey>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.InternalGroupBy<TKey, (T1, T2, T3, T4)>(exp?.Body);
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.InternalGroupBy<TKey, (T1, T2, T3, T4)>(exp?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4>.Max<TMember>(Expression<Func<T1, T2, T3, T4, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMax<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4>.Max<TMember>(Expression<Func<T1, T2, T3, T4, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMax<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4>.MaxAsync<TMember>(Expression<Func<T1, T2, T3, T4, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMaxAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4>.MaxAsync<TMember>(Expression<Func<T1, T2, T3, T4, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMaxAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4>.Min<TMember>(Expression<Func<T1, T2, T3, T4, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMin<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4>.Min<TMember>(Expression<Func<T1, T2, T3, T4, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMin<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4>.MinAsync<TMember>(Expression<Func<T1, T2, T3, T4, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMinAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4>.MinAsync<TMember>(Expression<Func<T1, T2, T3, T4, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMinAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4> ISelect<T1, T2, T3, T4>.OrderBy<TMember>(Expression<Func<T1, T2, T3, T4, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalOrderBy(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4> ISelect<T1, T2, T3, T4>.OrderBy<TMember>(Expression<Func<T1, T2, T3, T4, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalOrderBy(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4> ISelect<T1, T2, T3, T4>.OrderByDescending<TMember>(Expression<Func<T1, T2, T3, T4, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalOrderByDescending(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4> ISelect<T1, T2, T3, T4>.OrderByDescending<TMember>(Expression<Func<T1, T2, T3, T4, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalOrderByDescending(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4>.Sum<TMember>(Expression<Func<T1, T2, T3, T4, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalSum<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4>.Sum<TMember>(Expression<Func<T1, T2, T3, T4, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalSum<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4>.SumAsync<TMember>(Expression<Func<T1, T2, T3, T4, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalSumAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4>.SumAsync<TMember>(Expression<Func<T1, T2, T3, T4, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalSumAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TReturn ISelect<T1, T2, T3, T4>.ToAggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, TReturn>> select) {
 | 
			
		||||
			if (select == null) return default(TReturn);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToAggregate<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TReturn ISelect<T1, T2, T3, T4>.ToAggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return default(TReturn);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToAggregate<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TReturn> ISelect<T1, T2, T3, T4>.ToAggregateAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, TReturn>> select) {
 | 
			
		||||
			if (select == null) return Task.FromResult(default(TReturn));
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToAggregateAsync<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
		List<TReturn> ISelect<T1, T2, T3, T4>.ToList<TReturn>(Expression<Func<T1, T2, T3, T4, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
		List<TDto> ISelect<T1, T2, T3, T4>.ToList<TDto>() => (this as ISelect<T1, T2, T3, T4>).ToList(GetToListDtoSelector<TDto>());
 | 
			
		||||
		Task<List<TDto>> ISelect<T1, T2, T3, T4>.ToListAsync<TDto>() => (this as ISelect<T1, T2, T3, T4>).ToListAsync(GetToListDtoSelector<TDto>());
 | 
			
		||||
		Expression<Func<T1, T2, T3, T4, TDto>> GetToListDtoSelector<TDto>() {
 | 
			
		||||
			var ctor = typeof(TDto).GetConstructor(new Type[0]);
 | 
			
		||||
			return Expression.Lambda<Func<T1, T2, T3, T4, TDto>>(Expression.New(ctor),
 | 
			
		||||
				_tables[0].Parameter ?? Expression.Parameter(typeof(T1), "a"),
 | 
			
		||||
				Expression.Parameter(typeof(T2), "b"),
 | 
			
		||||
				Expression.Parameter(typeof(T3), "c"),
 | 
			
		||||
				Expression.Parameter(typeof(T4), "d"));
 | 
			
		||||
		}
 | 
			
		||||
        Task<TReturn> ISelect<T1, T2, T3, T4>.ToAggregateAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return Task.FromResult(default(TReturn));
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToAggregateAsync<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
        List<TReturn> ISelect<T1, T2, T3, T4>.ToList<TReturn>(Expression<Func<T1, T2, T3, T4, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
        List<TDto> ISelect<T1, T2, T3, T4>.ToList<TDto>() => (this as ISelect<T1, T2, T3, T4>).ToList(GetToListDtoSelector<TDto>());
 | 
			
		||||
        Task<List<TDto>> ISelect<T1, T2, T3, T4>.ToListAsync<TDto>() => (this as ISelect<T1, T2, T3, T4>).ToListAsync(GetToListDtoSelector<TDto>());
 | 
			
		||||
        Expression<Func<T1, T2, T3, T4, TDto>> GetToListDtoSelector<TDto>()
 | 
			
		||||
        {
 | 
			
		||||
            var ctor = typeof(TDto).GetConstructor(new Type[0]);
 | 
			
		||||
            return Expression.Lambda<Func<T1, T2, T3, T4, TDto>>(Expression.New(ctor),
 | 
			
		||||
                _tables[0].Parameter ?? Expression.Parameter(typeof(T1), "a"),
 | 
			
		||||
                Expression.Parameter(typeof(T2), "b"),
 | 
			
		||||
                Expression.Parameter(typeof(T3), "c"),
 | 
			
		||||
                Expression.Parameter(typeof(T4), "d"));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<List<TReturn>> ISelect<T1, T2, T3, T4>.ToListAsync<TReturn>(Expression<Func<T1, T2, T3, T4, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<List<TReturn>> ISelect<T1, T2, T3, T4>.ToListAsync<TReturn>(Expression<Func<T1, T2, T3, T4, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		DataTable ISelect<T1, T2, T3, T4>.ToDataTable<TReturn>(Expression<Func<T1, T2, T3, T4, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToDataTable(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToDataTable(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        DataTable ISelect<T1, T2, T3, T4>.ToDataTable<TReturn>(Expression<Func<T1, T2, T3, T4, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToDataTable(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToDataTable(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<DataTable> ISelect<T1, T2, T3, T4>.ToDataTableAsync<TReturn>(Expression<Func<T1, T2, T3, T4, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<DataTable> ISelect<T1, T2, T3, T4>.ToDataTableAsync<TReturn>(Expression<Func<T1, T2, T3, T4, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		string ISelect<T1, T2, T3, T4>.ToSql<TReturn>(Expression<Func<T1, T2, T3, T4, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        string ISelect<T1, T2, T3, T4>.ToSql<TReturn>(Expression<Func<T1, T2, T3, T4, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4> ISelect<T1, T2, T3, T4>.Where(Expression<Func<T1, T2, T3, T4, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.Where(null);
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4> ISelect<T1, T2, T3, T4>.Where(Expression<Func<T1, T2, T3, T4, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.Where(null);
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4> ISelect<T1, T2, T3, T4>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, bool>> exp) {
 | 
			
		||||
			if (condition == false || exp == null) return this;
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4> ISelect<T1, T2, T3, T4>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (condition == false || exp == null) return this;
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		bool ISelect<T1, T2, T3, T4>.Any(Expression<Func<T1, T2, T3, T4, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.Any();
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any();
 | 
			
		||||
		}
 | 
			
		||||
        bool ISelect<T1, T2, T3, T4>.Any(Expression<Func<T1, T2, T3, T4, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.Any();
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<bool> ISelect<T1, T2, T3, T4>.AnyAsync(Expression<Func<T1, T2, T3, T4, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.AnyAsync();
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
        Task<bool> ISelect<T1, T2, T3, T4>.AnyAsync(Expression<Func<T1, T2, T3, T4, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.AnyAsync();
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -5,163 +5,189 @@ using System.Data;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider {
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	public abstract class Select5Provider<T1, T2, T3, T4, T5> : Select0Provider<ISelect<T1, T2, T3, T4, T5>, T1>, ISelect<T1, T2, T3, T4, T5>
 | 
			
		||||
			where T1 : class
 | 
			
		||||
			where T2 : class
 | 
			
		||||
			where T3 : class
 | 
			
		||||
			where T4 : class
 | 
			
		||||
			where T5 : class {
 | 
			
		||||
    public abstract class Select5Provider<T1, T2, T3, T4, T5> : Select0Provider<ISelect<T1, T2, T3, T4, T5>, T1>, ISelect<T1, T2, T3, T4, T5>
 | 
			
		||||
            where T1 : class
 | 
			
		||||
            where T2 : class
 | 
			
		||||
            where T3 : class
 | 
			
		||||
            where T4 : class
 | 
			
		||||
            where T5 : class
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
		public Select5Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) {
 | 
			
		||||
			if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3), typeof(T4), typeof(T5));
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T4)), Alias = $"SP10d", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T5)), Alias = $"SP10e", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
		}
 | 
			
		||||
        public Select5Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere)
 | 
			
		||||
        {
 | 
			
		||||
            if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3), typeof(T4), typeof(T5));
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T4)), Alias = $"SP10d", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T5)), Alias = $"SP10e", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5>.Avg<TMember>(Expression<Func<T1, T2, T3, T4, T5, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalAvg<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5>.Avg<TMember>(Expression<Func<T1, T2, T3, T4, T5, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalAvg<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5>.AvgAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalAvgAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5>.AvgAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalAvgAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelectGrouping<TKey, (T1, T2, T3, T4, T5)> ISelect<T1, T2, T3, T4, T5>.GroupBy<TKey>(Expression<Func<T1, T2, T3, T4, T5, TKey>> exp) {
 | 
			
		||||
			if (exp == null) return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5)>(exp?.Body);
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5)>(exp?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelectGrouping<TKey, (T1, T2, T3, T4, T5)> ISelect<T1, T2, T3, T4, T5>.GroupBy<TKey>(Expression<Func<T1, T2, T3, T4, T5, TKey>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5)>(exp?.Body);
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5)>(exp?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5>.Max<TMember>(Expression<Func<T1, T2, T3, T4, T5, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMax<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5>.Max<TMember>(Expression<Func<T1, T2, T3, T4, T5, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMax<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5>.MaxAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMaxAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5>.MaxAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMaxAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5>.Min<TMember>(Expression<Func<T1, T2, T3, T4, T5, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMin<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5>.Min<TMember>(Expression<Func<T1, T2, T3, T4, T5, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMin<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5>.MinAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMinAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5>.MinAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMinAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5> ISelect<T1, T2, T3, T4, T5>.OrderBy<TMember>(Expression<Func<T1, T2, T3, T4, T5, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalOrderBy(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5> ISelect<T1, T2, T3, T4, T5>.OrderBy<TMember>(Expression<Func<T1, T2, T3, T4, T5, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalOrderBy(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5> ISelect<T1, T2, T3, T4, T5>.OrderByDescending<TMember>(Expression<Func<T1, T2, T3, T4, T5, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalOrderByDescending(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5> ISelect<T1, T2, T3, T4, T5>.OrderByDescending<TMember>(Expression<Func<T1, T2, T3, T4, T5, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalOrderByDescending(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5>.Sum<TMember>(Expression<Func<T1, T2, T3, T4, T5, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalSum<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5>.Sum<TMember>(Expression<Func<T1, T2, T3, T4, T5, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalSum<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5>.SumAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalSumAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5>.SumAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalSumAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TReturn ISelect<T1, T2, T3, T4, T5>.ToAggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, TReturn>> select) {
 | 
			
		||||
			if (select == null) return default(TReturn);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToAggregate<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TReturn ISelect<T1, T2, T3, T4, T5>.ToAggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return default(TReturn);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToAggregate<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TReturn> ISelect<T1, T2, T3, T4, T5>.ToAggregateAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, TReturn>> select) {
 | 
			
		||||
			if (select == null) return Task.FromResult(default(TReturn));
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToAggregateAsync<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TReturn> ISelect<T1, T2, T3, T4, T5>.ToAggregateAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return Task.FromResult(default(TReturn));
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToAggregateAsync<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		List<TReturn> ISelect<T1, T2, T3, T4, T5>.ToList<TReturn>(Expression<Func<T1, T2, T3, T4, T5, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
		Task<List<TReturn>> ISelect<T1, T2, T3, T4, T5>.ToListAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
		List<TDto> ISelect<T1, T2, T3, T4, T5>.ToList<TDto>() => (this as ISelect<T1, T2, T3, T4, T5>).ToList(GetToListDtoSelector<TDto>());
 | 
			
		||||
		Task<List<TDto>> ISelect<T1, T2, T3, T4, T5>.ToListAsync<TDto>() => (this as ISelect<T1, T2, T3, T4, T5>).ToListAsync(GetToListDtoSelector<TDto>());
 | 
			
		||||
		Expression<Func<T1, T2, T3, T4, T5, TDto>> GetToListDtoSelector<TDto>() {
 | 
			
		||||
			var ctor = typeof(TDto).GetConstructor(new Type[0]);
 | 
			
		||||
			return Expression.Lambda<Func<T1, T2, T3, T4, T5, TDto>>(Expression.New(ctor),
 | 
			
		||||
				_tables[0].Parameter ?? Expression.Parameter(typeof(T1), "a"),
 | 
			
		||||
				Expression.Parameter(typeof(T2), "b"),
 | 
			
		||||
				Expression.Parameter(typeof(T3), "c"),
 | 
			
		||||
				Expression.Parameter(typeof(T4), "d"),
 | 
			
		||||
				Expression.Parameter(typeof(T5), "e"));
 | 
			
		||||
		}
 | 
			
		||||
        List<TReturn> ISelect<T1, T2, T3, T4, T5>.ToList<TReturn>(Expression<Func<T1, T2, T3, T4, T5, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
        Task<List<TReturn>> ISelect<T1, T2, T3, T4, T5>.ToListAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
        List<TDto> ISelect<T1, T2, T3, T4, T5>.ToList<TDto>() => (this as ISelect<T1, T2, T3, T4, T5>).ToList(GetToListDtoSelector<TDto>());
 | 
			
		||||
        Task<List<TDto>> ISelect<T1, T2, T3, T4, T5>.ToListAsync<TDto>() => (this as ISelect<T1, T2, T3, T4, T5>).ToListAsync(GetToListDtoSelector<TDto>());
 | 
			
		||||
        Expression<Func<T1, T2, T3, T4, T5, TDto>> GetToListDtoSelector<TDto>()
 | 
			
		||||
        {
 | 
			
		||||
            var ctor = typeof(TDto).GetConstructor(new Type[0]);
 | 
			
		||||
            return Expression.Lambda<Func<T1, T2, T3, T4, T5, TDto>>(Expression.New(ctor),
 | 
			
		||||
                _tables[0].Parameter ?? Expression.Parameter(typeof(T1), "a"),
 | 
			
		||||
                Expression.Parameter(typeof(T2), "b"),
 | 
			
		||||
                Expression.Parameter(typeof(T3), "c"),
 | 
			
		||||
                Expression.Parameter(typeof(T4), "d"),
 | 
			
		||||
                Expression.Parameter(typeof(T5), "e"));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		DataTable ISelect<T1, T2, T3, T4, T5>.ToDataTable<TReturn>(Expression<Func<T1, T2, T3, T4, T5, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToDataTable(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToDataTable(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        DataTable ISelect<T1, T2, T3, T4, T5>.ToDataTable<TReturn>(Expression<Func<T1, T2, T3, T4, T5, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToDataTable(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToDataTable(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<DataTable> ISelect<T1, T2, T3, T4, T5>.ToDataTableAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<DataTable> ISelect<T1, T2, T3, T4, T5>.ToDataTableAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		string ISelect<T1, T2, T3, T4, T5>.ToSql<TReturn>(Expression<Func<T1, T2, T3, T4, T5, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        string ISelect<T1, T2, T3, T4, T5>.ToSql<TReturn>(Expression<Func<T1, T2, T3, T4, T5, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5> ISelect<T1, T2, T3, T4, T5>.Where(Expression<Func<T1, T2, T3, T4, T5, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.Where(null);
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5> ISelect<T1, T2, T3, T4, T5>.Where(Expression<Func<T1, T2, T3, T4, T5, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.Where(null);
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5> ISelect<T1, T2, T3, T4, T5>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, bool>> exp) {
 | 
			
		||||
			if (condition == false || exp == null) return this;
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5> ISelect<T1, T2, T3, T4, T5>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (condition == false || exp == null) return this;
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		bool ISelect<T1, T2, T3, T4, T5>.Any(Expression<Func<T1, T2, T3, T4, T5, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.Any();
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any();
 | 
			
		||||
		}
 | 
			
		||||
        bool ISelect<T1, T2, T3, T4, T5>.Any(Expression<Func<T1, T2, T3, T4, T5, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.Any();
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<bool> ISelect<T1, T2, T3, T4, T5>.AnyAsync(Expression<Func<T1, T2, T3, T4, T5, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.AnyAsync();
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
        Task<bool> ISelect<T1, T2, T3, T4, T5>.AnyAsync(Expression<Func<T1, T2, T3, T4, T5, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.AnyAsync();
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -5,166 +5,192 @@ using System.Data;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider {
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	public abstract class Select6Provider<T1, T2, T3, T4, T5, T6> : Select0Provider<ISelect<T1, T2, T3, T4, T5, T6>, T1>, ISelect<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 abstract class Select6Provider<T1, T2, T3, T4, T5, T6> : Select0Provider<ISelect<T1, T2, T3, T4, T5, T6>, T1>, ISelect<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 Select6Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) {
 | 
			
		||||
			if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6));
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T4)), Alias = $"SP10d", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T5)), Alias = $"SP10e", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T6)), Alias = $"SP10f", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
		}
 | 
			
		||||
        public Select6Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere)
 | 
			
		||||
        {
 | 
			
		||||
            if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6));
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T4)), Alias = $"SP10d", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T5)), Alias = $"SP10e", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T6)), Alias = $"SP10f", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5, T6>.Avg<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalAvg<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5, T6>.Avg<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalAvg<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5, T6>.AvgAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalAvgAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5, T6>.AvgAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalAvgAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelectGrouping<TKey, (T1, T2, T3, T4, T5, T6)> ISelect<T1, T2, T3, T4, T5, T6>.GroupBy<TKey>(Expression<Func<T1, T2, T3, T4, T5, T6, TKey>> exp) {
 | 
			
		||||
			if (exp == null) return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5, T6)>(exp?.Body);
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5, T6)>(exp?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelectGrouping<TKey, (T1, T2, T3, T4, T5, T6)> ISelect<T1, T2, T3, T4, T5, T6>.GroupBy<TKey>(Expression<Func<T1, T2, T3, T4, T5, T6, TKey>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5, T6)>(exp?.Body);
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5, T6)>(exp?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5, T6>.Max<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMax<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5, T6>.Max<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMax<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5, T6>.MaxAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMaxAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5, T6>.MaxAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMaxAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5, T6>.Min<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMin<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5, T6>.Min<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMin<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5, T6>.MinAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMinAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5, T6>.MinAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMinAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5, T6> ISelect<T1, T2, T3, T4, T5, T6>.OrderBy<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalOrderBy(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5, T6> ISelect<T1, T2, T3, T4, T5, T6>.OrderBy<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalOrderBy(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5, T6> ISelect<T1, T2, T3, T4, T5, T6>.OrderByDescending<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalOrderByDescending(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5, T6> ISelect<T1, T2, T3, T4, T5, T6>.OrderByDescending<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalOrderByDescending(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5, T6>.Sum<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalSum<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5, T6>.Sum<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalSum<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5, T6>.SumAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalSumAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5, T6>.SumAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalSumAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TReturn ISelect<T1, T2, T3, T4, T5, T6>.ToAggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, ISelectGroupingAggregate<T6>, TReturn>> select) {
 | 
			
		||||
			if (select == null) return default(TReturn);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToAggregate<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TReturn ISelect<T1, T2, T3, T4, T5, T6>.ToAggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, ISelectGroupingAggregate<T6>, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return default(TReturn);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToAggregate<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TReturn> ISelect<T1, T2, T3, T4, T5, T6>.ToAggregateAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, ISelectGroupingAggregate<T6>, TReturn>> select) {
 | 
			
		||||
			if (select == null) return Task.FromResult(default(TReturn));
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToAggregateAsync<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TReturn> ISelect<T1, T2, T3, T4, T5, T6>.ToAggregateAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, ISelectGroupingAggregate<T6>, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return Task.FromResult(default(TReturn));
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToAggregateAsync<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		List<TReturn> ISelect<T1, T2, T3, T4, T5, T6>.ToList<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
		Task<List<TReturn>> ISelect<T1, T2, T3, T4, T5, T6>.ToListAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
		List<TDto> ISelect<T1, T2, T3, T4, T5, T6>.ToList<TDto>() => (this as ISelect<T1, T2, T3, T4, T5, T6>).ToList(GetToListDtoSelector<TDto>());
 | 
			
		||||
		Task<List<TDto>> ISelect<T1, T2, T3, T4, T5, T6>.ToListAsync<TDto>() => (this as ISelect<T1, T2, T3, T4, T5, T6>).ToListAsync(GetToListDtoSelector<TDto>());
 | 
			
		||||
		Expression<Func<T1, T2, T3, T4, T5, T6, TDto>> GetToListDtoSelector<TDto>() {
 | 
			
		||||
			var ctor = typeof(TDto).GetConstructor(new Type[0]);
 | 
			
		||||
			return Expression.Lambda<Func<T1, T2, T3, T4, T5, T6, TDto>>(Expression.New(ctor),
 | 
			
		||||
				_tables[0].Parameter ?? Expression.Parameter(typeof(T1), "a"),
 | 
			
		||||
				Expression.Parameter(typeof(T2), "b"),
 | 
			
		||||
				Expression.Parameter(typeof(T3), "c"),
 | 
			
		||||
				Expression.Parameter(typeof(T4), "d"),
 | 
			
		||||
				Expression.Parameter(typeof(T5), "e"),
 | 
			
		||||
				Expression.Parameter(typeof(T6), "f"));
 | 
			
		||||
		}
 | 
			
		||||
        List<TReturn> ISelect<T1, T2, T3, T4, T5, T6>.ToList<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
        Task<List<TReturn>> ISelect<T1, T2, T3, T4, T5, T6>.ToListAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
        List<TDto> ISelect<T1, T2, T3, T4, T5, T6>.ToList<TDto>() => (this as ISelect<T1, T2, T3, T4, T5, T6>).ToList(GetToListDtoSelector<TDto>());
 | 
			
		||||
        Task<List<TDto>> ISelect<T1, T2, T3, T4, T5, T6>.ToListAsync<TDto>() => (this as ISelect<T1, T2, T3, T4, T5, T6>).ToListAsync(GetToListDtoSelector<TDto>());
 | 
			
		||||
        Expression<Func<T1, T2, T3, T4, T5, T6, TDto>> GetToListDtoSelector<TDto>()
 | 
			
		||||
        {
 | 
			
		||||
            var ctor = typeof(TDto).GetConstructor(new Type[0]);
 | 
			
		||||
            return Expression.Lambda<Func<T1, T2, T3, T4, T5, T6, TDto>>(Expression.New(ctor),
 | 
			
		||||
                _tables[0].Parameter ?? Expression.Parameter(typeof(T1), "a"),
 | 
			
		||||
                Expression.Parameter(typeof(T2), "b"),
 | 
			
		||||
                Expression.Parameter(typeof(T3), "c"),
 | 
			
		||||
                Expression.Parameter(typeof(T4), "d"),
 | 
			
		||||
                Expression.Parameter(typeof(T5), "e"),
 | 
			
		||||
                Expression.Parameter(typeof(T6), "f"));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		DataTable ISelect<T1, T2, T3, T4, T5, T6>.ToDataTable<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToDataTable(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToDataTable(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        DataTable ISelect<T1, T2, T3, T4, T5, T6>.ToDataTable<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToDataTable(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToDataTable(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<DataTable> ISelect<T1, T2, T3, T4, T5, T6>.ToDataTableAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<DataTable> ISelect<T1, T2, T3, T4, T5, T6>.ToDataTableAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		string ISelect<T1, T2, T3, T4, T5, T6>.ToSql<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        string ISelect<T1, T2, T3, T4, T5, T6>.ToSql<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5, T6> ISelect<T1, T2, T3, T4, T5, T6>.Where(Expression<Func<T1, T2, T3, T4, T5, T6, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.Where(null);
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5, T6> ISelect<T1, T2, T3, T4, T5, T6>.Where(Expression<Func<T1, T2, T3, T4, T5, T6, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.Where(null);
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5, T6> ISelect<T1, T2, T3, T4, T5, T6>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, bool>> exp) {
 | 
			
		||||
			if (condition == false || exp == null) return this;
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5, T6> ISelect<T1, T2, T3, T4, T5, T6>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (condition == false || exp == null) return this;
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		bool ISelect<T1, T2, T3, T4, T5, T6>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.Any();
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any();
 | 
			
		||||
		}
 | 
			
		||||
        bool ISelect<T1, T2, T3, T4, T5, T6>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.Any();
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<bool> ISelect<T1, T2, T3, T4, T5, T6>.AnyAsync(Expression<Func<T1, T2, T3, T4, T5, T6, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.AnyAsync();
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
        Task<bool> ISelect<T1, T2, T3, T4, T5, T6>.AnyAsync(Expression<Func<T1, T2, T3, T4, T5, T6, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.AnyAsync();
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -5,169 +5,195 @@ using System.Data;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider {
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	public abstract class Select7Provider<T1, T2, T3, T4, T5, T6, T7> : Select0Provider<ISelect<T1, T2, T3, T4, T5, T6, T7>, T1>, ISelect<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 abstract class Select7Provider<T1, T2, T3, T4, T5, T6, T7> : Select0Provider<ISelect<T1, T2, T3, T4, T5, T6, T7>, T1>, ISelect<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 Select7Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) {
 | 
			
		||||
			if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7));
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T4)), Alias = $"SP10d", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T5)), Alias = $"SP10e", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T6)), Alias = $"SP10f", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T7)), Alias = $"SP10g", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
		}
 | 
			
		||||
        public Select7Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere)
 | 
			
		||||
        {
 | 
			
		||||
            if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7));
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T4)), Alias = $"SP10d", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T5)), Alias = $"SP10e", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T6)), Alias = $"SP10f", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T7)), Alias = $"SP10g", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5, T6, T7>.Avg<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalAvg<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5, T6, T7>.Avg<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalAvg<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7>.AvgAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalAvgAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7>.AvgAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalAvgAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelectGrouping<TKey, (T1, T2, T3, T4, T5, T6, T7)> ISelect<T1, T2, T3, T4, T5, T6, T7>.GroupBy<TKey>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TKey>> exp) {
 | 
			
		||||
			if (exp == null) return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5, T6, T7)>(exp?.Body);
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5, T6, T7)>(exp?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelectGrouping<TKey, (T1, T2, T3, T4, T5, T6, T7)> ISelect<T1, T2, T3, T4, T5, T6, T7>.GroupBy<TKey>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TKey>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5, T6, T7)>(exp?.Body);
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5, T6, T7)>(exp?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5, T6, T7>.Max<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMax<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5, T6, T7>.Max<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMax<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7>.MaxAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMaxAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7>.MaxAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMaxAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5, T6, T7>.Min<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMin<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5, T6, T7>.Min<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMin<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7>.MinAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMinAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7>.MinAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMinAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5, T6, T7> ISelect<T1, T2, T3, T4, T5, T6, T7>.OrderBy<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalOrderBy(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5, T6, T7> ISelect<T1, T2, T3, T4, T5, T6, T7>.OrderBy<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalOrderBy(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5, T6, T7> ISelect<T1, T2, T3, T4, T5, T6, T7>.OrderByDescending<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalOrderByDescending(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5, T6, T7> ISelect<T1, T2, T3, T4, T5, T6, T7>.OrderByDescending<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalOrderByDescending(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5, T6, T7>.Sum<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalSum<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5, T6, T7>.Sum<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalSum<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7>.SumAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalSumAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7>.SumAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalSumAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TReturn ISelect<T1, T2, T3, T4, T5, T6, T7>.ToAggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, ISelectGroupingAggregate<T6>, ISelectGroupingAggregate<T7>, TReturn>> select) {
 | 
			
		||||
			if (select == null) return default(TReturn);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToAggregate<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TReturn ISelect<T1, T2, T3, T4, T5, T6, T7>.ToAggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, ISelectGroupingAggregate<T6>, ISelectGroupingAggregate<T7>, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return default(TReturn);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToAggregate<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TReturn> ISelect<T1, T2, T3, T4, T5, T6, T7>.ToAggregateAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, ISelectGroupingAggregate<T6>, ISelectGroupingAggregate<T7>, TReturn>> select) {
 | 
			
		||||
			if (select == null) return Task.FromResult(default(TReturn));
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToAggregateAsync<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TReturn> ISelect<T1, T2, T3, T4, T5, T6, T7>.ToAggregateAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, ISelectGroupingAggregate<T6>, ISelectGroupingAggregate<T7>, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return Task.FromResult(default(TReturn));
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToAggregateAsync<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		List<TReturn> ISelect<T1, T2, T3, T4, T5, T6, T7>.ToList<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
		Task<List<TReturn>> ISelect<T1, T2, T3, T4, T5, T6, T7>.ToListAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
		List<TDto> ISelect<T1, T2, T3, T4, T5, T6, T7>.ToList<TDto>() => (this as ISelect<T1, T2, T3, T4, T5, T6, T7>).ToList(GetToListDtoSelector<TDto>());
 | 
			
		||||
		Task<List<TDto>> ISelect<T1, T2, T3, T4, T5, T6, T7>.ToListAsync<TDto>() => (this as ISelect<T1, T2, T3, T4, T5, T6, T7>).ToListAsync(GetToListDtoSelector<TDto>());
 | 
			
		||||
		Expression<Func<T1, T2, T3, T4, T5, T6, T7, TDto>> GetToListDtoSelector<TDto>() {
 | 
			
		||||
			var ctor = typeof(TDto).GetConstructor(new Type[0]);
 | 
			
		||||
			return Expression.Lambda<Func<T1, T2, T3, T4, T5, T6, T7, TDto>>(Expression.New(ctor),
 | 
			
		||||
				_tables[0].Parameter ?? Expression.Parameter(typeof(T1), "a"),
 | 
			
		||||
				Expression.Parameter(typeof(T2), "b"),
 | 
			
		||||
				Expression.Parameter(typeof(T3), "c"),
 | 
			
		||||
				Expression.Parameter(typeof(T4), "d"),
 | 
			
		||||
				Expression.Parameter(typeof(T5), "e"),
 | 
			
		||||
				Expression.Parameter(typeof(T6), "f"),
 | 
			
		||||
				Expression.Parameter(typeof(T7), "g"));
 | 
			
		||||
		}
 | 
			
		||||
        List<TReturn> ISelect<T1, T2, T3, T4, T5, T6, T7>.ToList<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
        Task<List<TReturn>> ISelect<T1, T2, T3, T4, T5, T6, T7>.ToListAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
        List<TDto> ISelect<T1, T2, T3, T4, T5, T6, T7>.ToList<TDto>() => (this as ISelect<T1, T2, T3, T4, T5, T6, T7>).ToList(GetToListDtoSelector<TDto>());
 | 
			
		||||
        Task<List<TDto>> ISelect<T1, T2, T3, T4, T5, T6, T7>.ToListAsync<TDto>() => (this as ISelect<T1, T2, T3, T4, T5, T6, T7>).ToListAsync(GetToListDtoSelector<TDto>());
 | 
			
		||||
        Expression<Func<T1, T2, T3, T4, T5, T6, T7, TDto>> GetToListDtoSelector<TDto>()
 | 
			
		||||
        {
 | 
			
		||||
            var ctor = typeof(TDto).GetConstructor(new Type[0]);
 | 
			
		||||
            return Expression.Lambda<Func<T1, T2, T3, T4, T5, T6, T7, TDto>>(Expression.New(ctor),
 | 
			
		||||
                _tables[0].Parameter ?? Expression.Parameter(typeof(T1), "a"),
 | 
			
		||||
                Expression.Parameter(typeof(T2), "b"),
 | 
			
		||||
                Expression.Parameter(typeof(T3), "c"),
 | 
			
		||||
                Expression.Parameter(typeof(T4), "d"),
 | 
			
		||||
                Expression.Parameter(typeof(T5), "e"),
 | 
			
		||||
                Expression.Parameter(typeof(T6), "f"),
 | 
			
		||||
                Expression.Parameter(typeof(T7), "g"));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		DataTable ISelect<T1, T2, T3, T4, T5, T6, T7>.ToDataTable<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToDataTable(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToDataTable(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        DataTable ISelect<T1, T2, T3, T4, T5, T6, T7>.ToDataTable<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToDataTable(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToDataTable(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<DataTable> ISelect<T1, T2, T3, T4, T5, T6, T7>.ToDataTableAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<DataTable> ISelect<T1, T2, T3, T4, T5, T6, T7>.ToDataTableAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		string ISelect<T1, T2, T3, T4, T5, T6, T7>.ToSql<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        string ISelect<T1, T2, T3, T4, T5, T6, T7>.ToSql<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5, T6, T7> ISelect<T1, T2, T3, T4, T5, T6, T7>.Where(Expression<Func<T1, T2, T3, T4, T5, T6, T7, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.Where(null);
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5, T6, T7> ISelect<T1, T2, T3, T4, T5, T6, T7>.Where(Expression<Func<T1, T2, T3, T4, T5, T6, T7, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.Where(null);
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5, T6, T7> ISelect<T1, T2, T3, T4, T5, T6, T7>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, bool>> exp) {
 | 
			
		||||
			if (condition == false || exp == null) return this;
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5, T6, T7> ISelect<T1, T2, T3, T4, T5, T6, T7>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (condition == false || exp == null) return this;
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		bool ISelect<T1, T2, T3, T4, T5, T6, T7>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.Any();
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any();
 | 
			
		||||
		}
 | 
			
		||||
        bool ISelect<T1, T2, T3, T4, T5, T6, T7>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.Any();
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<bool> ISelect<T1, T2, T3, T4, T5, T6, T7>.AnyAsync(Expression<Func<T1, T2, T3, T4, T5, T6, T7, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.AnyAsync();
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
        Task<bool> ISelect<T1, T2, T3, T4, T5, T6, T7>.AnyAsync(Expression<Func<T1, T2, T3, T4, T5, T6, T7, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.AnyAsync();
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -5,172 +5,198 @@ using System.Data;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider {
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	public abstract class Select8Provider<T1, T2, T3, T4, T5, T6, T7, T8> : Select0Provider<ISelect<T1, T2, T3, T4, T5, T6, T7, T8>, T1>, ISelect<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 abstract class Select8Provider<T1, T2, T3, T4, T5, T6, T7, T8> : Select0Provider<ISelect<T1, T2, T3, T4, T5, T6, T7, T8>, T1>, ISelect<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 Select8Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) {
 | 
			
		||||
			if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8));
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T4)), Alias = $"SP10d", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T5)), Alias = $"SP10e", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T6)), Alias = $"SP10f", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T7)), Alias = $"SP10g", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T8)), Alias = $"SP10h", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
		}
 | 
			
		||||
        public Select8Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere)
 | 
			
		||||
        {
 | 
			
		||||
            if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8));
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T4)), Alias = $"SP10d", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T5)), Alias = $"SP10e", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T6)), Alias = $"SP10f", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T7)), Alias = $"SP10g", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T8)), Alias = $"SP10h", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.Avg<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalAvg<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.Avg<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalAvg<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.AvgAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalAvgAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.AvgAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalAvgAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelectGrouping<TKey, (T1, T2, T3, T4, T5, T6, T7, T8)> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.GroupBy<TKey>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TKey>> exp) {
 | 
			
		||||
			if (exp == null) return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5, T6, T7, T8)>(exp?.Body);
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5, T6, T7, T8)>(exp?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelectGrouping<TKey, (T1, T2, T3, T4, T5, T6, T7, T8)> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.GroupBy<TKey>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TKey>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5, T6, T7, T8)>(exp?.Body);
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5, T6, T7, T8)>(exp?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.Max<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMax<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.Max<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMax<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.MaxAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMaxAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.MaxAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMaxAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.Min<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMin<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.Min<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMin<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.MinAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMinAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.MinAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMinAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5, T6, T7, T8> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.OrderBy<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalOrderBy(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5, T6, T7, T8> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.OrderBy<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalOrderBy(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5, T6, T7, T8> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.OrderByDescending<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalOrderByDescending(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5, T6, T7, T8> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.OrderByDescending<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalOrderByDescending(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.Sum<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalSum<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.Sum<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalSum<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.SumAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalSumAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.SumAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalSumAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TReturn ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.ToAggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, ISelectGroupingAggregate<T6>, ISelectGroupingAggregate<T7>, ISelectGroupingAggregate<T8>, TReturn>> select) {
 | 
			
		||||
			if (select == null) return default(TReturn);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToAggregate<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TReturn ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.ToAggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, ISelectGroupingAggregate<T6>, ISelectGroupingAggregate<T7>, ISelectGroupingAggregate<T8>, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return default(TReturn);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToAggregate<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TReturn> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.ToAggregateAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, ISelectGroupingAggregate<T6>, ISelectGroupingAggregate<T7>, ISelectGroupingAggregate<T8>, TReturn>> select) {
 | 
			
		||||
			if (select == null) return Task.FromResult(default(TReturn));
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToAggregateAsync<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TReturn> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.ToAggregateAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, ISelectGroupingAggregate<T6>, ISelectGroupingAggregate<T7>, ISelectGroupingAggregate<T8>, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return Task.FromResult(default(TReturn));
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToAggregateAsync<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		List<TReturn> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.ToList<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
		Task<List<TReturn>> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.ToListAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
		List<TDto> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.ToList<TDto>() => (this as ISelect<T1, T2, T3, T4, T5, T6, T7, T8>).ToList(GetToListDtoSelector<TDto>());
 | 
			
		||||
		Task<List<TDto>> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.ToListAsync<TDto>() => (this as ISelect<T1, T2, T3, T4, T5, T6, T7, T8>).ToListAsync(GetToListDtoSelector<TDto>());
 | 
			
		||||
		Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TDto>> GetToListDtoSelector<TDto>() {
 | 
			
		||||
			var ctor = typeof(TDto).GetConstructor(new Type[0]);
 | 
			
		||||
			return Expression.Lambda<Func<T1, T2, T3, T4, T5, T6, T7, T8, TDto>>(Expression.New(ctor),
 | 
			
		||||
				_tables[0].Parameter ?? Expression.Parameter(typeof(T1), "a"),
 | 
			
		||||
				Expression.Parameter(typeof(T2), "b"),
 | 
			
		||||
				Expression.Parameter(typeof(T3), "c"),
 | 
			
		||||
				Expression.Parameter(typeof(T4), "d"),
 | 
			
		||||
				Expression.Parameter(typeof(T5), "e"),
 | 
			
		||||
				Expression.Parameter(typeof(T6), "f"),
 | 
			
		||||
				Expression.Parameter(typeof(T7), "g"),
 | 
			
		||||
				Expression.Parameter(typeof(T8), "h"));
 | 
			
		||||
		}
 | 
			
		||||
        List<TReturn> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.ToList<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
        Task<List<TReturn>> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.ToListAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
        List<TDto> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.ToList<TDto>() => (this as ISelect<T1, T2, T3, T4, T5, T6, T7, T8>).ToList(GetToListDtoSelector<TDto>());
 | 
			
		||||
        Task<List<TDto>> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.ToListAsync<TDto>() => (this as ISelect<T1, T2, T3, T4, T5, T6, T7, T8>).ToListAsync(GetToListDtoSelector<TDto>());
 | 
			
		||||
        Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TDto>> GetToListDtoSelector<TDto>()
 | 
			
		||||
        {
 | 
			
		||||
            var ctor = typeof(TDto).GetConstructor(new Type[0]);
 | 
			
		||||
            return Expression.Lambda<Func<T1, T2, T3, T4, T5, T6, T7, T8, TDto>>(Expression.New(ctor),
 | 
			
		||||
                _tables[0].Parameter ?? Expression.Parameter(typeof(T1), "a"),
 | 
			
		||||
                Expression.Parameter(typeof(T2), "b"),
 | 
			
		||||
                Expression.Parameter(typeof(T3), "c"),
 | 
			
		||||
                Expression.Parameter(typeof(T4), "d"),
 | 
			
		||||
                Expression.Parameter(typeof(T5), "e"),
 | 
			
		||||
                Expression.Parameter(typeof(T6), "f"),
 | 
			
		||||
                Expression.Parameter(typeof(T7), "g"),
 | 
			
		||||
                Expression.Parameter(typeof(T8), "h"));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		DataTable ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.ToDataTable<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToDataTable(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToDataTable(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        DataTable ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.ToDataTable<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToDataTable(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToDataTable(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<DataTable> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.ToDataTableAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<DataTable> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.ToDataTableAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		string ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.ToSql<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        string ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.ToSql<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5, T6, T7, T8> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.Where(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.Where(null);
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5, T6, T7, T8> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.Where(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.Where(null);
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5, T6, T7, T8> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, bool>> exp) {
 | 
			
		||||
			if (condition == false || exp == null) return this;
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5, T6, T7, T8> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (condition == false || exp == null) return this;
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		bool ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.Any();
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any();
 | 
			
		||||
		}
 | 
			
		||||
        bool ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.Any();
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<bool> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.AnyAsync(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.AnyAsync();
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
        Task<bool> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.AnyAsync(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.AnyAsync();
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -5,175 +5,201 @@ using System.Data;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider {
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	public abstract class Select9Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9> : Select0Provider<ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>, T1>, ISelect<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 abstract class Select9Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9> : Select0Provider<ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>, T1>, ISelect<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 Select9Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) {
 | 
			
		||||
			if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9));
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T4)), Alias = $"SP10d", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T5)), Alias = $"SP10e", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T6)), Alias = $"SP10f", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T7)), Alias = $"SP10g", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T8)), Alias = $"SP10h", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
			_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T9)), Alias = $"SP10i", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
		}
 | 
			
		||||
        public Select9Provider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere)
 | 
			
		||||
        {
 | 
			
		||||
            if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9));
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T2)), Alias = $"SP10b", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T3)), Alias = $"SP10c", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T4)), Alias = $"SP10d", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T5)), Alias = $"SP10e", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T6)), Alias = $"SP10f", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T7)), Alias = $"SP10g", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T8)), Alias = $"SP10h", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
            _tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T9)), Alias = $"SP10i", On = null, Type = SelectTableInfoType.From });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.Avg<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalAvg<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.Avg<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalAvg<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.AvgAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalAvgAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.AvgAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalAvgAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelectGrouping<TKey, (T1, T2, T3, T4, T5, T6, T7, T8, T9)> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.GroupBy<TKey>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TKey>> exp) {
 | 
			
		||||
			if (exp == null) return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5, T6, T7, T8, T9)>(exp?.Body);
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5, T6, T7, T8, T9)>(exp?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelectGrouping<TKey, (T1, T2, T3, T4, T5, T6, T7, T8, T9)> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.GroupBy<TKey>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TKey>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5, T6, T7, T8, T9)>(exp?.Body);
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.InternalGroupBy<TKey, (T1, T2, T3, T4, T5, T6, T7, T8, T9)>(exp?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.Max<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMax<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.Max<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMax<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.MaxAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMaxAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.MaxAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMaxAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.Min<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TMember>> column) {
 | 
			
		||||
			if (column == null) return default(TMember);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMin<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.Min<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return default(TMember);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMin<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.MinAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TMember>> column) {
 | 
			
		||||
			if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalMinAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.MinAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) return Task.FromResult(default(TMember));
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalMinAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.OrderBy<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalOrderBy(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.OrderBy<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalOrderBy(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.OrderByDescending<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalOrderByDescending(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.OrderByDescending<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalOrderByDescending(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.Sum<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalSum<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TMember ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.Sum<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalSum<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.SumAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TMember>> column) {
 | 
			
		||||
			if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
			for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
			return this.InternalSumAsync<TMember>(column?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TMember> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.SumAsync<TMember>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            if (column == null) this.InternalOrderBy(column?.Body);
 | 
			
		||||
            for (var a = 0; a < column.Parameters.Count; a++) _tables[a].Parameter = column.Parameters[a];
 | 
			
		||||
            return this.InternalSumAsync<TMember>(column?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		TReturn ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.ToAggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, ISelectGroupingAggregate<T6>, ISelectGroupingAggregate<T7>, ISelectGroupingAggregate<T8>, ISelectGroupingAggregate<T9>, TReturn>> select) {
 | 
			
		||||
			if (select == null) return default(TReturn);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToAggregate<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        TReturn ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.ToAggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, ISelectGroupingAggregate<T6>, ISelectGroupingAggregate<T7>, ISelectGroupingAggregate<T8>, ISelectGroupingAggregate<T9>, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return default(TReturn);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToAggregate<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<TReturn> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.ToAggregateAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, ISelectGroupingAggregate<T6>, ISelectGroupingAggregate<T7>, ISelectGroupingAggregate<T8>, ISelectGroupingAggregate<T9>, TReturn>> select) {
 | 
			
		||||
			if (select == null) return Task.FromResult(default(TReturn));
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToAggregateAsync<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<TReturn> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.ToAggregateAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, ISelectGroupingAggregate<T2>, ISelectGroupingAggregate<T3>, ISelectGroupingAggregate<T4>, ISelectGroupingAggregate<T5>, ISelectGroupingAggregate<T6>, ISelectGroupingAggregate<T7>, ISelectGroupingAggregate<T8>, ISelectGroupingAggregate<T9>, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return Task.FromResult(default(TReturn));
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToAggregateAsync<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		List<TReturn> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.ToList<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
		Task<List<TReturn>> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.ToListAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
		List<TDto> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.ToList<TDto>() => (this as ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>).ToList(GetToListDtoSelector<TDto>());
 | 
			
		||||
		Task<List<TDto>> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.ToListAsync<TDto>() => (this as ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>).ToListAsync(GetToListDtoSelector<TDto>());
 | 
			
		||||
		Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TDto>> GetToListDtoSelector<TDto>() {
 | 
			
		||||
			var ctor = typeof(TDto).GetConstructor(new Type[0]);
 | 
			
		||||
			return Expression.Lambda<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TDto>>(Expression.New(ctor),
 | 
			
		||||
				_tables[0].Parameter ?? Expression.Parameter(typeof(T1), "a"),
 | 
			
		||||
				Expression.Parameter(typeof(T2), "b"),
 | 
			
		||||
				Expression.Parameter(typeof(T3), "c"),
 | 
			
		||||
				Expression.Parameter(typeof(T4), "d"),
 | 
			
		||||
				Expression.Parameter(typeof(T5), "e"),
 | 
			
		||||
				Expression.Parameter(typeof(T6), "f"),
 | 
			
		||||
				Expression.Parameter(typeof(T7), "g"),
 | 
			
		||||
				Expression.Parameter(typeof(T8), "h"),
 | 
			
		||||
				Expression.Parameter(typeof(T9), "i"));
 | 
			
		||||
		}
 | 
			
		||||
        List<TReturn> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.ToList<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToList<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
        Task<List<TReturn>> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.ToListAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToListAsync<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
        List<TDto> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.ToList<TDto>() => (this as ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>).ToList(GetToListDtoSelector<TDto>());
 | 
			
		||||
        Task<List<TDto>> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.ToListAsync<TDto>() => (this as ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>).ToListAsync(GetToListDtoSelector<TDto>());
 | 
			
		||||
        Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TDto>> GetToListDtoSelector<TDto>()
 | 
			
		||||
        {
 | 
			
		||||
            var ctor = typeof(TDto).GetConstructor(new Type[0]);
 | 
			
		||||
            return Expression.Lambda<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TDto>>(Expression.New(ctor),
 | 
			
		||||
                _tables[0].Parameter ?? Expression.Parameter(typeof(T1), "a"),
 | 
			
		||||
                Expression.Parameter(typeof(T2), "b"),
 | 
			
		||||
                Expression.Parameter(typeof(T3), "c"),
 | 
			
		||||
                Expression.Parameter(typeof(T4), "d"),
 | 
			
		||||
                Expression.Parameter(typeof(T5), "e"),
 | 
			
		||||
                Expression.Parameter(typeof(T6), "f"),
 | 
			
		||||
                Expression.Parameter(typeof(T7), "g"),
 | 
			
		||||
                Expression.Parameter(typeof(T8), "h"),
 | 
			
		||||
                Expression.Parameter(typeof(T9), "i"));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		DataTable ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.ToDataTable<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToDataTable(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToDataTable(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        DataTable ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.ToDataTable<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToDataTable(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToDataTable(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<DataTable> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.ToDataTableAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        Task<DataTable> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.ToDataTableAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToDataTableAsync(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		string ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.ToSql<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>> select) {
 | 
			
		||||
			if (select == null) return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
			for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
			return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
		}
 | 
			
		||||
        string ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.ToSql<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            if (select == null) return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
            for (var a = 0; a < select.Parameters.Count; a++) _tables[a].Parameter = select.Parameters[a];
 | 
			
		||||
            return this.InternalToSql<TReturn>(select?.Body);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.Where(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.Where(null);
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.Where(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.Where(null);
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, bool>> exp) {
 | 
			
		||||
			if (condition == false || exp == null) return this;
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
		}
 | 
			
		||||
        ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (condition == false || exp == null) return this;
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		bool ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.Any();
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any();
 | 
			
		||||
		}
 | 
			
		||||
        bool ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.Any();
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).Any();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Task<bool> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.AnyAsync(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, bool>> exp) {
 | 
			
		||||
			if (exp == null) return this.AnyAsync();
 | 
			
		||||
			for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
			return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
        Task<bool> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.AnyAsync(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            if (exp == null) return this.AnyAsync();
 | 
			
		||||
            for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
 | 
			
		||||
            return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)).AnyAsync();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -7,140 +7,161 @@ using System.Reflection;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider {
 | 
			
		||||
	public class SelectGroupingProvider<TKey, TValue> : ISelectGrouping<TKey, TValue> {
 | 
			
		||||
namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
{
 | 
			
		||||
    public class SelectGroupingProvider<TKey, TValue> : ISelectGrouping<TKey, TValue>
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
		internal object _select;
 | 
			
		||||
		internal ReadAnonymousTypeInfo _map;
 | 
			
		||||
		internal CommonExpression _comonExp;
 | 
			
		||||
		internal List<SelectTableInfo> _tables;
 | 
			
		||||
		public SelectGroupingProvider(object select, ReadAnonymousTypeInfo map, CommonExpression comonExp, List<SelectTableInfo> tables) {
 | 
			
		||||
			_select = select;
 | 
			
		||||
			_map = map;
 | 
			
		||||
			_comonExp = comonExp;
 | 
			
		||||
			_tables = tables;
 | 
			
		||||
		}
 | 
			
		||||
        internal object _select;
 | 
			
		||||
        internal ReadAnonymousTypeInfo _map;
 | 
			
		||||
        internal CommonExpression _comonExp;
 | 
			
		||||
        internal List<SelectTableInfo> _tables;
 | 
			
		||||
        public SelectGroupingProvider(object select, ReadAnonymousTypeInfo map, CommonExpression comonExp, List<SelectTableInfo> tables)
 | 
			
		||||
        {
 | 
			
		||||
            _select = select;
 | 
			
		||||
            _map = map;
 | 
			
		||||
            _comonExp = comonExp;
 | 
			
		||||
            _tables = tables;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		string getSelectGroupingMapString(Expression[] members) {
 | 
			
		||||
			if (members.Any() == false) return _map.DbField;
 | 
			
		||||
			var parentName = ((members.FirstOrDefault() as MemberExpression)?.Expression as MemberExpression)?.Member.Name;
 | 
			
		||||
			switch (parentName) {
 | 
			
		||||
				case "Key":
 | 
			
		||||
					var read = _map;
 | 
			
		||||
					for (var a = 0; a < members.Length; a++) {
 | 
			
		||||
						read = read.Childs.Where(z => z.CsName == (members[a] as MemberExpression)?.Member.Name).FirstOrDefault();
 | 
			
		||||
						if (read == null) return null;
 | 
			
		||||
					}
 | 
			
		||||
					return read.DbField;
 | 
			
		||||
				case "Value":
 | 
			
		||||
					var tb = _tables.First();
 | 
			
		||||
					var foridx = 0;
 | 
			
		||||
					if (members.Length > 1) {
 | 
			
		||||
						var mem0 = (members.FirstOrDefault() as MemberExpression);
 | 
			
		||||
						var mem0Name = mem0?.Member.Name;
 | 
			
		||||
						if (mem0Name?.StartsWith("Item") == true && int.TryParse(mem0Name.Substring(4), out var tryitemidx)) {
 | 
			
		||||
							if (tryitemidx == 1) foridx++;
 | 
			
		||||
							else {
 | 
			
		||||
								//var alias = $"SP10{(char)(96 + tryitemidx)}";
 | 
			
		||||
								var tmptb = _tables.Where((a,idx) => //a.AliasInit == alias && 
 | 
			
		||||
									a.Table.Type == mem0.Type && idx == tryitemidx - 1).FirstOrDefault();
 | 
			
		||||
								if (tmptb != null) {
 | 
			
		||||
									tb = tmptb;
 | 
			
		||||
									foridx++;
 | 
			
		||||
								}
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
					var parmExp = Expression.Parameter(tb.Table.Type, tb.Alias);
 | 
			
		||||
					Expression retExp = parmExp;
 | 
			
		||||
					for (var a = foridx; a < members.Length; a++) {
 | 
			
		||||
						switch (members[a].NodeType) {
 | 
			
		||||
							case ExpressionType.Call:
 | 
			
		||||
								retExp = Expression.Call(retExp, (members[a] as MethodCallExpression).Method);
 | 
			
		||||
								break;
 | 
			
		||||
							case ExpressionType.MemberAccess:
 | 
			
		||||
								retExp = Expression.MakeMemberAccess(retExp, (members[a] as MemberExpression).Member);
 | 
			
		||||
								break;
 | 
			
		||||
							default:
 | 
			
		||||
								return null;
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
					return _comonExp.ExpressionLambdaToSql(retExp, new CommonExpression.ExpTSC { _tables = _tables, tbtype = SelectTableInfoType.From, isQuoteName = true, isDisableDiyParse = true, style = CommonExpression.ExpressionStyle.Where });
 | 
			
		||||
			}
 | 
			
		||||
			return null;
 | 
			
		||||
		}
 | 
			
		||||
        string getSelectGroupingMapString(Expression[] members)
 | 
			
		||||
        {
 | 
			
		||||
            if (members.Any() == false) return _map.DbField;
 | 
			
		||||
            var parentName = ((members.FirstOrDefault() as MemberExpression)?.Expression as MemberExpression)?.Member.Name;
 | 
			
		||||
            switch (parentName)
 | 
			
		||||
            {
 | 
			
		||||
                case "Key":
 | 
			
		||||
                    var read = _map;
 | 
			
		||||
                    for (var a = 0; a < members.Length; a++)
 | 
			
		||||
                    {
 | 
			
		||||
                        read = read.Childs.Where(z => z.CsName == (members[a] as MemberExpression)?.Member.Name).FirstOrDefault();
 | 
			
		||||
                        if (read == null) return null;
 | 
			
		||||
                    }
 | 
			
		||||
                    return read.DbField;
 | 
			
		||||
                case "Value":
 | 
			
		||||
                    var tb = _tables.First();
 | 
			
		||||
                    var foridx = 0;
 | 
			
		||||
                    if (members.Length > 1)
 | 
			
		||||
                    {
 | 
			
		||||
                        var mem0 = (members.FirstOrDefault() as MemberExpression);
 | 
			
		||||
                        var mem0Name = mem0?.Member.Name;
 | 
			
		||||
                        if (mem0Name?.StartsWith("Item") == true && int.TryParse(mem0Name.Substring(4), out var tryitemidx))
 | 
			
		||||
                        {
 | 
			
		||||
                            if (tryitemidx == 1) foridx++;
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                //var alias = $"SP10{(char)(96 + tryitemidx)}";
 | 
			
		||||
                                var tmptb = _tables.Where((a, idx) => //a.AliasInit == alias && 
 | 
			
		||||
                                    a.Table.Type == mem0.Type && idx == tryitemidx - 1).FirstOrDefault();
 | 
			
		||||
                                if (tmptb != null)
 | 
			
		||||
                                {
 | 
			
		||||
                                    tb = tmptb;
 | 
			
		||||
                                    foridx++;
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    var parmExp = Expression.Parameter(tb.Table.Type, tb.Alias);
 | 
			
		||||
                    Expression retExp = parmExp;
 | 
			
		||||
                    for (var a = foridx; a < members.Length; a++)
 | 
			
		||||
                    {
 | 
			
		||||
                        switch (members[a].NodeType)
 | 
			
		||||
                        {
 | 
			
		||||
                            case ExpressionType.Call:
 | 
			
		||||
                                retExp = Expression.Call(retExp, (members[a] as MethodCallExpression).Method);
 | 
			
		||||
                                break;
 | 
			
		||||
                            case ExpressionType.MemberAccess:
 | 
			
		||||
                                retExp = Expression.MakeMemberAccess(retExp, (members[a] as MemberExpression).Member);
 | 
			
		||||
                                break;
 | 
			
		||||
                            default:
 | 
			
		||||
                                return null;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    return _comonExp.ExpressionLambdaToSql(retExp, new CommonExpression.ExpTSC { _tables = _tables, tbtype = SelectTableInfoType.From, isQuoteName = true, isDisableDiyParse = true, style = CommonExpression.ExpressionStyle.Where });
 | 
			
		||||
            }
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		public ISelectGrouping<TKey, TValue> Having(Expression<Func<ISelectGroupingAggregate<TKey, TValue>, bool>> exp) {
 | 
			
		||||
			var sql = _comonExp.ExpressionWhereLambda(null, exp, getSelectGroupingMapString);
 | 
			
		||||
			var method = _select.GetType().GetMethod("Having", new[] { typeof(string), typeof(object) });
 | 
			
		||||
			method.Invoke(_select, new object[] { sql, null });
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
        public ISelectGrouping<TKey, TValue> Having(Expression<Func<ISelectGroupingAggregate<TKey, TValue>, bool>> exp)
 | 
			
		||||
        {
 | 
			
		||||
            var sql = _comonExp.ExpressionWhereLambda(null, exp, getSelectGroupingMapString);
 | 
			
		||||
            var method = _select.GetType().GetMethod("Having", new[] { typeof(string), typeof(object) });
 | 
			
		||||
            method.Invoke(_select, new object[] { sql, null });
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		public ISelectGrouping<TKey, TValue> OrderBy<TMember>(Expression<Func<ISelectGroupingAggregate<TKey, TValue>, TMember>> column) {
 | 
			
		||||
			var sql = _comonExp.ExpressionWhereLambda(null, column, getSelectGroupingMapString);
 | 
			
		||||
			var method = _select.GetType().GetMethod("OrderBy", new[] { typeof(string), typeof(object) });
 | 
			
		||||
			method.Invoke(_select, new object[] { sql, null });
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
        public ISelectGrouping<TKey, TValue> OrderBy<TMember>(Expression<Func<ISelectGroupingAggregate<TKey, TValue>, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            var sql = _comonExp.ExpressionWhereLambda(null, column, getSelectGroupingMapString);
 | 
			
		||||
            var method = _select.GetType().GetMethod("OrderBy", new[] { typeof(string), typeof(object) });
 | 
			
		||||
            method.Invoke(_select, new object[] { sql, null });
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		public ISelectGrouping<TKey, TValue> OrderByDescending<TMember>(Expression<Func<ISelectGroupingAggregate<TKey, TValue>, TMember>> column) {
 | 
			
		||||
			var sql = _comonExp.ExpressionWhereLambda(null, column, getSelectGroupingMapString);
 | 
			
		||||
			var method = _select.GetType().GetMethod("OrderBy", new[] { typeof(string), typeof(object) });
 | 
			
		||||
			method.Invoke(_select, new object[] { $"{sql} DESC", null });
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
        public ISelectGrouping<TKey, TValue> OrderByDescending<TMember>(Expression<Func<ISelectGroupingAggregate<TKey, TValue>, TMember>> column)
 | 
			
		||||
        {
 | 
			
		||||
            var sql = _comonExp.ExpressionWhereLambda(null, column, getSelectGroupingMapString);
 | 
			
		||||
            var method = _select.GetType().GetMethod("OrderBy", new[] { typeof(string), typeof(object) });
 | 
			
		||||
            method.Invoke(_select, new object[] { $"{sql} DESC", null });
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		public List<TReturn> ToList<TReturn>(Expression<Func<ISelectGroupingAggregate<TKey, TValue>, TReturn>> select) {
 | 
			
		||||
			var map = new ReadAnonymousTypeInfo();
 | 
			
		||||
			var field = new StringBuilder();
 | 
			
		||||
			var index = 0;
 | 
			
		||||
        public List<TReturn> ToList<TReturn>(Expression<Func<ISelectGroupingAggregate<TKey, TValue>, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            var map = new ReadAnonymousTypeInfo();
 | 
			
		||||
            var field = new StringBuilder();
 | 
			
		||||
            var index = 0;
 | 
			
		||||
 | 
			
		||||
			_comonExp.ReadAnonymousField(null, field, map, ref index, select, getSelectGroupingMapString);
 | 
			
		||||
			var method = _select.GetType().GetMethod("ToListMapReader", BindingFlags.Instance | BindingFlags.NonPublic);
 | 
			
		||||
			method = method.MakeGenericMethod(typeof(TReturn));
 | 
			
		||||
			return method.Invoke(_select, new object[] { (map, field.Length > 0 ? field.Remove(0, 2).ToString() : null) }) as List<TReturn>;
 | 
			
		||||
		}
 | 
			
		||||
		public Task<List<TReturn>> ToListAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<TKey, TValue>, TReturn>> select) {
 | 
			
		||||
			var map = new ReadAnonymousTypeInfo();
 | 
			
		||||
			var field = new StringBuilder();
 | 
			
		||||
			var index = 0;
 | 
			
		||||
            _comonExp.ReadAnonymousField(null, field, map, ref index, select, getSelectGroupingMapString);
 | 
			
		||||
            var method = _select.GetType().GetMethod("ToListMapReader", BindingFlags.Instance | BindingFlags.NonPublic);
 | 
			
		||||
            method = method.MakeGenericMethod(typeof(TReturn));
 | 
			
		||||
            return method.Invoke(_select, new object[] { (map, field.Length > 0 ? field.Remove(0, 2).ToString() : null) }) as List<TReturn>;
 | 
			
		||||
        }
 | 
			
		||||
        public Task<List<TReturn>> ToListAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<TKey, TValue>, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            var map = new ReadAnonymousTypeInfo();
 | 
			
		||||
            var field = new StringBuilder();
 | 
			
		||||
            var index = 0;
 | 
			
		||||
 | 
			
		||||
			_comonExp.ReadAnonymousField(null, field, map, ref index, select, getSelectGroupingMapString);
 | 
			
		||||
			var method = _select.GetType().GetMethod("ToListMapReaderAsync", BindingFlags.Instance | BindingFlags.NonPublic);
 | 
			
		||||
			method = method.MakeGenericMethod(typeof(TReturn));
 | 
			
		||||
			return method.Invoke(_select, new object[] { (map, field.Length > 0 ? field.Remove(0, 2).ToString() : null) }) as Task<List<TReturn>>;
 | 
			
		||||
		}
 | 
			
		||||
		public List<TReturn> Select<TReturn>(Expression<Func<ISelectGroupingAggregate<TKey, TValue>, TReturn>> select) => ToList(select);
 | 
			
		||||
            _comonExp.ReadAnonymousField(null, field, map, ref index, select, getSelectGroupingMapString);
 | 
			
		||||
            var method = _select.GetType().GetMethod("ToListMapReaderAsync", BindingFlags.Instance | BindingFlags.NonPublic);
 | 
			
		||||
            method = method.MakeGenericMethod(typeof(TReturn));
 | 
			
		||||
            return method.Invoke(_select, new object[] { (map, field.Length > 0 ? field.Remove(0, 2).ToString() : null) }) as Task<List<TReturn>>;
 | 
			
		||||
        }
 | 
			
		||||
        public List<TReturn> Select<TReturn>(Expression<Func<ISelectGroupingAggregate<TKey, TValue>, TReturn>> select) => ToList(select);
 | 
			
		||||
 | 
			
		||||
		public string ToSql<TReturn>(Expression<Func<ISelectGroupingAggregate<TKey, TValue>, TReturn>> select) {
 | 
			
		||||
			var map = new ReadAnonymousTypeInfo();
 | 
			
		||||
			var field = new StringBuilder();
 | 
			
		||||
			var index = 0;
 | 
			
		||||
        public string ToSql<TReturn>(Expression<Func<ISelectGroupingAggregate<TKey, TValue>, TReturn>> select)
 | 
			
		||||
        {
 | 
			
		||||
            var map = new ReadAnonymousTypeInfo();
 | 
			
		||||
            var field = new StringBuilder();
 | 
			
		||||
            var index = 0;
 | 
			
		||||
 | 
			
		||||
			_comonExp.ReadAnonymousField(null, field, map, ref index, select, getSelectGroupingMapString);
 | 
			
		||||
			var method = _select.GetType().GetMethod("ToSql", new[] { typeof(string) });
 | 
			
		||||
			return method.Invoke(_select, new object[] { field.Length > 0 ? field.Remove(0, 2).ToString() : null }) as string;
 | 
			
		||||
		}
 | 
			
		||||
            _comonExp.ReadAnonymousField(null, field, map, ref index, select, getSelectGroupingMapString);
 | 
			
		||||
            var method = _select.GetType().GetMethod("ToSql", new[] { typeof(string) });
 | 
			
		||||
            return method.Invoke(_select, new object[] { field.Length > 0 ? field.Remove(0, 2).ToString() : null }) as string;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		public ISelectGrouping<TKey, TValue> Skip(int offset) {
 | 
			
		||||
			var method = _select.GetType().GetMethod("Skip", new[] { typeof(int) });
 | 
			
		||||
			method.Invoke(_select, new object[] { offset });
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
		public ISelectGrouping<TKey, TValue> Offset(int offset) => this.Skip(offset);
 | 
			
		||||
        public ISelectGrouping<TKey, TValue> Skip(int offset)
 | 
			
		||||
        {
 | 
			
		||||
            var method = _select.GetType().GetMethod("Skip", new[] { typeof(int) });
 | 
			
		||||
            method.Invoke(_select, new object[] { offset });
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
        public ISelectGrouping<TKey, TValue> Offset(int offset) => this.Skip(offset);
 | 
			
		||||
 | 
			
		||||
		public ISelectGrouping<TKey, TValue> Limit(int limit) {
 | 
			
		||||
			var method = _select.GetType().GetMethod("Limit", new[] { typeof(int) });
 | 
			
		||||
			method.Invoke(_select, new object[] { limit });
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
		public ISelectGrouping<TKey, TValue> Take(int limit) => this.Limit(limit);
 | 
			
		||||
        public ISelectGrouping<TKey, TValue> Limit(int limit)
 | 
			
		||||
        {
 | 
			
		||||
            var method = _select.GetType().GetMethod("Limit", new[] { typeof(int) });
 | 
			
		||||
            method.Invoke(_select, new object[] { limit });
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
        public ISelectGrouping<TKey, TValue> Take(int limit) => this.Limit(limit);
 | 
			
		||||
 | 
			
		||||
		public ISelectGrouping<TKey, TValue> Page(int pageNumber, int pageSize) {
 | 
			
		||||
			var method = _select.GetType().GetMethod("Page", new[] { typeof(int), typeof(int) });
 | 
			
		||||
			method.Invoke(_select, new object[] { pageNumber, pageSize });
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
        public ISelectGrouping<TKey, TValue> Page(int pageNumber, int pageSize)
 | 
			
		||||
        {
 | 
			
		||||
            var method = _select.GetType().GetMethod("Page", new[] { typeof(int), typeof(int) });
 | 
			
		||||
            method.Invoke(_select, new object[] { pageNumber, pageSize });
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -17,293 +17,339 @@ using System.Threading.Tasks;
 | 
			
		||||
using System.Xml;
 | 
			
		||||
using System.Xml.XPath;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal {
 | 
			
		||||
	public abstract class CommonUtils {
 | 
			
		||||
namespace FreeSql.Internal
 | 
			
		||||
{
 | 
			
		||||
    public abstract class CommonUtils
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
		public abstract string GetNoneParamaterSqlValue(List<DbParameter> specialParams, Type type, object value);
 | 
			
		||||
		public abstract DbParameter AppendParamter(List<DbParameter> _params, string parameterName, Type type, object value);
 | 
			
		||||
		public abstract DbParameter[] GetDbParamtersByObject(string sql, object obj);
 | 
			
		||||
		public abstract string FormatSql(string sql, params object[] args);
 | 
			
		||||
		public abstract string QuoteSqlName(string name);
 | 
			
		||||
		public abstract string TrimQuoteSqlName(string name);
 | 
			
		||||
		public abstract string QuoteParamterName(string name);
 | 
			
		||||
		public abstract string IsNull(string sql, object value);
 | 
			
		||||
		public abstract string StringConcat(string[] objs, Type[] types);
 | 
			
		||||
		public abstract string Mod(string left, string right, Type leftType, Type rightType);
 | 
			
		||||
		public abstract string QuoteWriteParamter(Type type, string paramterName);
 | 
			
		||||
		public abstract string QuoteReadColumn(Type type, string columnName);
 | 
			
		||||
        public abstract string GetNoneParamaterSqlValue(List<DbParameter> specialParams, Type type, object value);
 | 
			
		||||
        public abstract DbParameter AppendParamter(List<DbParameter> _params, string parameterName, Type type, object value);
 | 
			
		||||
        public abstract DbParameter[] GetDbParamtersByObject(string sql, object obj);
 | 
			
		||||
        public abstract string FormatSql(string sql, params object[] args);
 | 
			
		||||
        public abstract string QuoteSqlName(string name);
 | 
			
		||||
        public abstract string TrimQuoteSqlName(string name);
 | 
			
		||||
        public abstract string QuoteParamterName(string name);
 | 
			
		||||
        public abstract string IsNull(string sql, object value);
 | 
			
		||||
        public abstract string StringConcat(string[] objs, Type[] types);
 | 
			
		||||
        public abstract string Mod(string left, string right, Type leftType, Type rightType);
 | 
			
		||||
        public abstract string QuoteWriteParamter(Type type, string paramterName);
 | 
			
		||||
        public abstract string QuoteReadColumn(Type type, string columnName);
 | 
			
		||||
 | 
			
		||||
		public IFreeSql _orm { get; set; }
 | 
			
		||||
		public ICodeFirst CodeFirst => _orm.CodeFirst;
 | 
			
		||||
		public TableInfo GetTableByEntity(Type entity) => Utils.GetTableByEntity(entity, this);
 | 
			
		||||
		public List<DbTableInfo> dbTables { get; set; }
 | 
			
		||||
		public object dbTablesLock = new object();
 | 
			
		||||
        public IFreeSql _orm { get; set; }
 | 
			
		||||
        public ICodeFirst CodeFirst => _orm.CodeFirst;
 | 
			
		||||
        public TableInfo GetTableByEntity(Type entity) => Utils.GetTableByEntity(entity, this);
 | 
			
		||||
        public List<DbTableInfo> dbTables { get; set; }
 | 
			
		||||
        public object dbTablesLock = new object();
 | 
			
		||||
 | 
			
		||||
		public CommonUtils(IFreeSql orm) {
 | 
			
		||||
			_orm = orm;
 | 
			
		||||
		}
 | 
			
		||||
        public CommonUtils(IFreeSql orm)
 | 
			
		||||
        {
 | 
			
		||||
            _orm = orm;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		ConcurrentDictionary<Type, TableAttribute> dicConfigEntity = new ConcurrentDictionary<Type, TableAttribute>();
 | 
			
		||||
		public ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity) {
 | 
			
		||||
			if (entity == null) return _orm.CodeFirst;
 | 
			
		||||
			var type = typeof(T);
 | 
			
		||||
			var table = dicConfigEntity.GetOrAdd(type, new TableAttribute());
 | 
			
		||||
			var fluent = new TableFluent<T>(table);
 | 
			
		||||
			entity.Invoke(fluent);
 | 
			
		||||
			Utils.RemoveTableByEntity(type, this); //remove cache
 | 
			
		||||
			return _orm.CodeFirst;
 | 
			
		||||
		}
 | 
			
		||||
		public ICodeFirst ConfigEntity(Type type, Action<TableFluent> entity) {
 | 
			
		||||
			if (entity == null) return _orm.CodeFirst;
 | 
			
		||||
			var table = dicConfigEntity.GetOrAdd(type, new TableAttribute());
 | 
			
		||||
			var fluent = new TableFluent(type, table);
 | 
			
		||||
			entity.Invoke(fluent);
 | 
			
		||||
			Utils.RemoveTableByEntity(type, this); //remove cache
 | 
			
		||||
			return _orm.CodeFirst;
 | 
			
		||||
		}
 | 
			
		||||
		public TableAttribute GetConfigEntity(Type type) {
 | 
			
		||||
			return dicConfigEntity.TryGetValue(type, out var trytb) ? trytb : null;
 | 
			
		||||
		}
 | 
			
		||||
		public TableAttribute GetEntityTableAttribute(Type type) {
 | 
			
		||||
			TableAttribute attr = null;
 | 
			
		||||
			if (_orm.Aop.ConfigEntity != null) {
 | 
			
		||||
				var aope = new Aop.ConfigEntityEventArgs(type);
 | 
			
		||||
				_orm.Aop.ConfigEntity(_orm, aope);
 | 
			
		||||
				attr = aope.ModifyResult;
 | 
			
		||||
			}
 | 
			
		||||
			if (attr == null) attr = new TableAttribute();
 | 
			
		||||
			if (dicConfigEntity.TryGetValue(type, out var trytb)) {
 | 
			
		||||
				if (!string.IsNullOrEmpty(trytb.Name)) attr.Name = trytb.Name;
 | 
			
		||||
				if (!string.IsNullOrEmpty(trytb.OldName)) attr.OldName = trytb.OldName;
 | 
			
		||||
				if (!string.IsNullOrEmpty(trytb.SelectFilter)) attr.SelectFilter = trytb.SelectFilter;
 | 
			
		||||
				if (trytb._DisableSyncStructure != null) attr._DisableSyncStructure = trytb.DisableSyncStructure;
 | 
			
		||||
        ConcurrentDictionary<Type, TableAttribute> dicConfigEntity = new ConcurrentDictionary<Type, TableAttribute>();
 | 
			
		||||
        public ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity)
 | 
			
		||||
        {
 | 
			
		||||
            if (entity == null) return _orm.CodeFirst;
 | 
			
		||||
            var type = typeof(T);
 | 
			
		||||
            var table = dicConfigEntity.GetOrAdd(type, new TableAttribute());
 | 
			
		||||
            var fluent = new TableFluent<T>(table);
 | 
			
		||||
            entity.Invoke(fluent);
 | 
			
		||||
            Utils.RemoveTableByEntity(type, this); //remove cache
 | 
			
		||||
            return _orm.CodeFirst;
 | 
			
		||||
        }
 | 
			
		||||
        public ICodeFirst ConfigEntity(Type type, Action<TableFluent> entity)
 | 
			
		||||
        {
 | 
			
		||||
            if (entity == null) return _orm.CodeFirst;
 | 
			
		||||
            var table = dicConfigEntity.GetOrAdd(type, new TableAttribute());
 | 
			
		||||
            var fluent = new TableFluent(type, table);
 | 
			
		||||
            entity.Invoke(fluent);
 | 
			
		||||
            Utils.RemoveTableByEntity(type, this); //remove cache
 | 
			
		||||
            return _orm.CodeFirst;
 | 
			
		||||
        }
 | 
			
		||||
        public TableAttribute GetConfigEntity(Type type)
 | 
			
		||||
        {
 | 
			
		||||
            return dicConfigEntity.TryGetValue(type, out var trytb) ? trytb : null;
 | 
			
		||||
        }
 | 
			
		||||
        public TableAttribute GetEntityTableAttribute(Type type)
 | 
			
		||||
        {
 | 
			
		||||
            TableAttribute attr = null;
 | 
			
		||||
            if (_orm.Aop.ConfigEntity != null)
 | 
			
		||||
            {
 | 
			
		||||
                var aope = new Aop.ConfigEntityEventArgs(type);
 | 
			
		||||
                _orm.Aop.ConfigEntity(_orm, aope);
 | 
			
		||||
                attr = aope.ModifyResult;
 | 
			
		||||
            }
 | 
			
		||||
            if (attr == null) attr = new TableAttribute();
 | 
			
		||||
            if (dicConfigEntity.TryGetValue(type, out var trytb))
 | 
			
		||||
            {
 | 
			
		||||
                if (!string.IsNullOrEmpty(trytb.Name)) attr.Name = trytb.Name;
 | 
			
		||||
                if (!string.IsNullOrEmpty(trytb.OldName)) attr.OldName = trytb.OldName;
 | 
			
		||||
                if (!string.IsNullOrEmpty(trytb.SelectFilter)) attr.SelectFilter = trytb.SelectFilter;
 | 
			
		||||
                if (trytb._DisableSyncStructure != null) attr._DisableSyncStructure = trytb.DisableSyncStructure;
 | 
			
		||||
 | 
			
		||||
			}
 | 
			
		||||
			var attrs = type.GetCustomAttributes(typeof(TableAttribute), false);
 | 
			
		||||
			foreach (var tryattrobj in attrs) {
 | 
			
		||||
				var tryattr = tryattrobj as TableAttribute;
 | 
			
		||||
				if (tryattr == null) continue;
 | 
			
		||||
				if (!string.IsNullOrEmpty(tryattr.Name)) attr.Name = tryattr.Name;
 | 
			
		||||
				if (!string.IsNullOrEmpty(tryattr.OldName)) attr.OldName = tryattr.OldName;
 | 
			
		||||
				if (!string.IsNullOrEmpty(tryattr.SelectFilter)) attr.SelectFilter = tryattr.SelectFilter;
 | 
			
		||||
				if (tryattr._DisableSyncStructure != null) attr._DisableSyncStructure = tryattr.DisableSyncStructure;
 | 
			
		||||
			}
 | 
			
		||||
			if (!string.IsNullOrEmpty(attr.Name)) return attr;
 | 
			
		||||
			if (!string.IsNullOrEmpty(attr.OldName)) return attr;
 | 
			
		||||
			if (!string.IsNullOrEmpty(attr.SelectFilter)) return attr;
 | 
			
		||||
			if (attr._DisableSyncStructure != null) return attr;
 | 
			
		||||
			return null;
 | 
			
		||||
		}
 | 
			
		||||
		public ColumnAttribute GetEntityColumnAttribute(Type type, PropertyInfo proto) {
 | 
			
		||||
			ColumnAttribute attr = null;
 | 
			
		||||
			if (_orm.Aop.ConfigEntityProperty != null) {
 | 
			
		||||
				var aope = new Aop.ConfigEntityPropertyEventArgs(type, proto);
 | 
			
		||||
				_orm.Aop.ConfigEntityProperty(_orm, aope);
 | 
			
		||||
				attr = aope.ModifyResult;
 | 
			
		||||
			}
 | 
			
		||||
			if (attr == null) attr = new ColumnAttribute();
 | 
			
		||||
			if (dicConfigEntity.TryGetValue(type, out var trytb) && trytb._columns.TryGetValue(proto.Name, out var trycol)) {
 | 
			
		||||
				if (!string.IsNullOrEmpty(trycol.Name)) attr.Name = trycol.Name;
 | 
			
		||||
				if (!string.IsNullOrEmpty(trycol.OldName)) attr.OldName = trycol.OldName;
 | 
			
		||||
				if (!string.IsNullOrEmpty(trycol.DbType)) attr.DbType = trycol.DbType;
 | 
			
		||||
				if (trycol._IsPrimary != null) attr._IsPrimary = trycol.IsPrimary;
 | 
			
		||||
				if (trycol._IsIdentity != null) attr._IsIdentity = trycol.IsIdentity;
 | 
			
		||||
				if (trycol._IsNullable != null) attr._IsNullable = trycol.IsNullable;
 | 
			
		||||
				if (trycol._IsIgnore != null) attr._IsIgnore = trycol.IsIgnore;
 | 
			
		||||
				if (trycol._IsVersion != null) attr._IsVersion = trycol.IsVersion;
 | 
			
		||||
				if (trycol._Uniques != null) attr._Uniques = trycol._Uniques;
 | 
			
		||||
				if (trycol.MapType != null) attr.MapType = trycol.MapType;
 | 
			
		||||
				if (trycol.DbDefautValue != null) attr.DbDefautValue = trycol.DbDefautValue;
 | 
			
		||||
			}
 | 
			
		||||
			var attrs = proto.GetCustomAttributes(typeof(ColumnAttribute), false);
 | 
			
		||||
			foreach (var tryattrobj in attrs) {
 | 
			
		||||
				var tryattr = tryattrobj as ColumnAttribute;
 | 
			
		||||
				if (tryattr == null) continue;
 | 
			
		||||
				if (!string.IsNullOrEmpty(tryattr.Name)) attr.Name = tryattr.Name;
 | 
			
		||||
				if (!string.IsNullOrEmpty(tryattr.OldName)) attr.OldName = tryattr.OldName;
 | 
			
		||||
				if (!string.IsNullOrEmpty(tryattr.DbType)) attr.DbType = tryattr.DbType;
 | 
			
		||||
				if (tryattr._IsPrimary != null) attr._IsPrimary = tryattr.IsPrimary;
 | 
			
		||||
				if (tryattr._IsIdentity != null) attr._IsIdentity = tryattr.IsIdentity;
 | 
			
		||||
				if (tryattr._IsNullable != null) attr._IsNullable = tryattr.IsNullable;
 | 
			
		||||
				if (tryattr._IsIgnore != null) attr._IsIgnore = tryattr.IsIgnore;
 | 
			
		||||
				if (tryattr._IsVersion != null) attr._IsVersion = tryattr.IsVersion;
 | 
			
		||||
				if (tryattr._Uniques != null) attr._Uniques = tryattr._Uniques;
 | 
			
		||||
				if (tryattr.MapType != null) attr.MapType = tryattr.MapType;
 | 
			
		||||
				if (tryattr.DbDefautValue != null) attr.DbDefautValue = tryattr.DbDefautValue;
 | 
			
		||||
			}
 | 
			
		||||
			ColumnAttribute ret = null;
 | 
			
		||||
			if (!string.IsNullOrEmpty(attr.Name)) ret = attr;
 | 
			
		||||
			if (!string.IsNullOrEmpty(attr.OldName)) ret = attr;
 | 
			
		||||
			if (!string.IsNullOrEmpty(attr.DbType)) ret = attr;
 | 
			
		||||
			if (attr._IsPrimary != null) ret = attr;
 | 
			
		||||
			if (attr._IsIdentity != null) ret = attr;
 | 
			
		||||
			if (attr._IsNullable != null) ret = attr;
 | 
			
		||||
			if (attr._IsIgnore != null) ret = attr;
 | 
			
		||||
			if (attr._IsVersion != null) ret = attr;
 | 
			
		||||
			if (attr._Uniques != null) ret = attr;
 | 
			
		||||
			if (attr.MapType != null) ret = attr;
 | 
			
		||||
			if (attr.DbDefautValue != null) ret = attr;
 | 
			
		||||
			if (ret != null && ret.MapType == null) ret.MapType = proto.PropertyType;
 | 
			
		||||
			return ret;
 | 
			
		||||
		}
 | 
			
		||||
            }
 | 
			
		||||
            var attrs = type.GetCustomAttributes(typeof(TableAttribute), false);
 | 
			
		||||
            foreach (var tryattrobj in attrs)
 | 
			
		||||
            {
 | 
			
		||||
                var tryattr = tryattrobj as TableAttribute;
 | 
			
		||||
                if (tryattr == null) continue;
 | 
			
		||||
                if (!string.IsNullOrEmpty(tryattr.Name)) attr.Name = tryattr.Name;
 | 
			
		||||
                if (!string.IsNullOrEmpty(tryattr.OldName)) attr.OldName = tryattr.OldName;
 | 
			
		||||
                if (!string.IsNullOrEmpty(tryattr.SelectFilter)) attr.SelectFilter = tryattr.SelectFilter;
 | 
			
		||||
                if (tryattr._DisableSyncStructure != null) attr._DisableSyncStructure = tryattr.DisableSyncStructure;
 | 
			
		||||
            }
 | 
			
		||||
            if (!string.IsNullOrEmpty(attr.Name)) return attr;
 | 
			
		||||
            if (!string.IsNullOrEmpty(attr.OldName)) return attr;
 | 
			
		||||
            if (!string.IsNullOrEmpty(attr.SelectFilter)) return attr;
 | 
			
		||||
            if (attr._DisableSyncStructure != null) return attr;
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        public ColumnAttribute GetEntityColumnAttribute(Type type, PropertyInfo proto)
 | 
			
		||||
        {
 | 
			
		||||
            ColumnAttribute attr = null;
 | 
			
		||||
            if (_orm.Aop.ConfigEntityProperty != null)
 | 
			
		||||
            {
 | 
			
		||||
                var aope = new Aop.ConfigEntityPropertyEventArgs(type, proto);
 | 
			
		||||
                _orm.Aop.ConfigEntityProperty(_orm, aope);
 | 
			
		||||
                attr = aope.ModifyResult;
 | 
			
		||||
            }
 | 
			
		||||
            if (attr == null) attr = new ColumnAttribute();
 | 
			
		||||
            if (dicConfigEntity.TryGetValue(type, out var trytb) && trytb._columns.TryGetValue(proto.Name, out var trycol))
 | 
			
		||||
            {
 | 
			
		||||
                if (!string.IsNullOrEmpty(trycol.Name)) attr.Name = trycol.Name;
 | 
			
		||||
                if (!string.IsNullOrEmpty(trycol.OldName)) attr.OldName = trycol.OldName;
 | 
			
		||||
                if (!string.IsNullOrEmpty(trycol.DbType)) attr.DbType = trycol.DbType;
 | 
			
		||||
                if (trycol._IsPrimary != null) attr._IsPrimary = trycol.IsPrimary;
 | 
			
		||||
                if (trycol._IsIdentity != null) attr._IsIdentity = trycol.IsIdentity;
 | 
			
		||||
                if (trycol._IsNullable != null) attr._IsNullable = trycol.IsNullable;
 | 
			
		||||
                if (trycol._IsIgnore != null) attr._IsIgnore = trycol.IsIgnore;
 | 
			
		||||
                if (trycol._IsVersion != null) attr._IsVersion = trycol.IsVersion;
 | 
			
		||||
                if (trycol._Uniques != null) attr._Uniques = trycol._Uniques;
 | 
			
		||||
                if (trycol.MapType != null) attr.MapType = trycol.MapType;
 | 
			
		||||
                if (trycol.DbDefautValue != null) attr.DbDefautValue = trycol.DbDefautValue;
 | 
			
		||||
            }
 | 
			
		||||
            var attrs = proto.GetCustomAttributes(typeof(ColumnAttribute), false);
 | 
			
		||||
            foreach (var tryattrobj in attrs)
 | 
			
		||||
            {
 | 
			
		||||
                var tryattr = tryattrobj as ColumnAttribute;
 | 
			
		||||
                if (tryattr == null) continue;
 | 
			
		||||
                if (!string.IsNullOrEmpty(tryattr.Name)) attr.Name = tryattr.Name;
 | 
			
		||||
                if (!string.IsNullOrEmpty(tryattr.OldName)) attr.OldName = tryattr.OldName;
 | 
			
		||||
                if (!string.IsNullOrEmpty(tryattr.DbType)) attr.DbType = tryattr.DbType;
 | 
			
		||||
                if (tryattr._IsPrimary != null) attr._IsPrimary = tryattr.IsPrimary;
 | 
			
		||||
                if (tryattr._IsIdentity != null) attr._IsIdentity = tryattr.IsIdentity;
 | 
			
		||||
                if (tryattr._IsNullable != null) attr._IsNullable = tryattr.IsNullable;
 | 
			
		||||
                if (tryattr._IsIgnore != null) attr._IsIgnore = tryattr.IsIgnore;
 | 
			
		||||
                if (tryattr._IsVersion != null) attr._IsVersion = tryattr.IsVersion;
 | 
			
		||||
                if (tryattr._Uniques != null) attr._Uniques = tryattr._Uniques;
 | 
			
		||||
                if (tryattr.MapType != null) attr.MapType = tryattr.MapType;
 | 
			
		||||
                if (tryattr.DbDefautValue != null) attr.DbDefautValue = tryattr.DbDefautValue;
 | 
			
		||||
            }
 | 
			
		||||
            ColumnAttribute ret = null;
 | 
			
		||||
            if (!string.IsNullOrEmpty(attr.Name)) ret = attr;
 | 
			
		||||
            if (!string.IsNullOrEmpty(attr.OldName)) ret = attr;
 | 
			
		||||
            if (!string.IsNullOrEmpty(attr.DbType)) ret = attr;
 | 
			
		||||
            if (attr._IsPrimary != null) ret = attr;
 | 
			
		||||
            if (attr._IsIdentity != null) ret = attr;
 | 
			
		||||
            if (attr._IsNullable != null) ret = attr;
 | 
			
		||||
            if (attr._IsIgnore != null) ret = attr;
 | 
			
		||||
            if (attr._IsVersion != null) ret = attr;
 | 
			
		||||
            if (attr._Uniques != null) ret = attr;
 | 
			
		||||
            if (attr.MapType != null) ret = attr;
 | 
			
		||||
            if (attr.DbDefautValue != null) ret = attr;
 | 
			
		||||
            if (ret != null && ret.MapType == null) ret.MapType = proto.PropertyType;
 | 
			
		||||
            return ret;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		public string WhereObject(TableInfo table, string aliasAndDot, object dywhere) {
 | 
			
		||||
			if (dywhere == null) return "";
 | 
			
		||||
			var type = dywhere.GetType();
 | 
			
		||||
			var primarys = table.Primarys;
 | 
			
		||||
			var pk1 = primarys.FirstOrDefault();
 | 
			
		||||
			if (primarys.Length == 1 && (type == pk1.CsType || type.IsNumberType() && pk1.CsType.IsNumberType())) {
 | 
			
		||||
				return $"{aliasAndDot}{this.QuoteSqlName(pk1.Attribute.Name)} = {this.FormatSql("{0}", Utils.GetDataReaderValue(pk1.Attribute.MapType, dywhere))}";
 | 
			
		||||
			} else if (primarys.Length > 0 && (type == table.Type || type.BaseType == table.Type)) {
 | 
			
		||||
				var sb = new StringBuilder();
 | 
			
		||||
				var pkidx = 0;
 | 
			
		||||
				foreach (var pk in primarys) {
 | 
			
		||||
					if (pkidx > 0) sb.Append(" AND ");
 | 
			
		||||
					sb.Append(aliasAndDot).Append(this.QuoteSqlName(pk.Attribute.Name));
 | 
			
		||||
					sb.Append(this.FormatSql(" = {0}", pk.GetMapValue(dywhere)));
 | 
			
		||||
					++pkidx;
 | 
			
		||||
				}
 | 
			
		||||
				return sb.ToString();
 | 
			
		||||
			} else if (dywhere is IEnumerable) {
 | 
			
		||||
				var sb = new StringBuilder();
 | 
			
		||||
				var ie = dywhere as IEnumerable;
 | 
			
		||||
				var ieidx = 0;
 | 
			
		||||
				foreach (var i in ie) {
 | 
			
		||||
					var fw = WhereObject(table, aliasAndDot, i);
 | 
			
		||||
					if (string.IsNullOrEmpty(fw)) continue;
 | 
			
		||||
					if (ieidx > 0) sb.Append(" OR ");
 | 
			
		||||
					sb.Append(fw);
 | 
			
		||||
					++ieidx;
 | 
			
		||||
				}
 | 
			
		||||
				return sb.ToString();
 | 
			
		||||
			} else {
 | 
			
		||||
				var sb = new StringBuilder();
 | 
			
		||||
				var ps = type.GetProperties();
 | 
			
		||||
				var psidx = 0;
 | 
			
		||||
				foreach (var p in ps) {
 | 
			
		||||
					if (table.Columns.TryGetValue(p.Name, out var trycol) == false) continue;
 | 
			
		||||
					if (psidx > 0) sb.Append(" AND ");
 | 
			
		||||
					sb.Append(aliasAndDot).Append(this.QuoteSqlName(trycol.Attribute.Name));
 | 
			
		||||
					sb.Append(this.FormatSql(" = {0}", Utils.GetDataReaderValue(trycol.Attribute.MapType, p.GetValue(dywhere))));
 | 
			
		||||
					++psidx;
 | 
			
		||||
				}
 | 
			
		||||
				if (psidx == 0) return "";
 | 
			
		||||
				return sb.ToString();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
        public string WhereObject(TableInfo table, string aliasAndDot, object dywhere)
 | 
			
		||||
        {
 | 
			
		||||
            if (dywhere == null) return "";
 | 
			
		||||
            var type = dywhere.GetType();
 | 
			
		||||
            var primarys = table.Primarys;
 | 
			
		||||
            var pk1 = primarys.FirstOrDefault();
 | 
			
		||||
            if (primarys.Length == 1 && (type == pk1.CsType || type.IsNumberType() && pk1.CsType.IsNumberType()))
 | 
			
		||||
            {
 | 
			
		||||
                return $"{aliasAndDot}{this.QuoteSqlName(pk1.Attribute.Name)} = {this.FormatSql("{0}", Utils.GetDataReaderValue(pk1.Attribute.MapType, dywhere))}";
 | 
			
		||||
            }
 | 
			
		||||
            else if (primarys.Length > 0 && (type == table.Type || type.BaseType == table.Type))
 | 
			
		||||
            {
 | 
			
		||||
                var sb = new StringBuilder();
 | 
			
		||||
                var pkidx = 0;
 | 
			
		||||
                foreach (var pk in primarys)
 | 
			
		||||
                {
 | 
			
		||||
                    if (pkidx > 0) sb.Append(" AND ");
 | 
			
		||||
                    sb.Append(aliasAndDot).Append(this.QuoteSqlName(pk.Attribute.Name));
 | 
			
		||||
                    sb.Append(this.FormatSql(" = {0}", pk.GetMapValue(dywhere)));
 | 
			
		||||
                    ++pkidx;
 | 
			
		||||
                }
 | 
			
		||||
                return sb.ToString();
 | 
			
		||||
            }
 | 
			
		||||
            else if (dywhere is IEnumerable)
 | 
			
		||||
            {
 | 
			
		||||
                var sb = new StringBuilder();
 | 
			
		||||
                var ie = dywhere as IEnumerable;
 | 
			
		||||
                var ieidx = 0;
 | 
			
		||||
                foreach (var i in ie)
 | 
			
		||||
                {
 | 
			
		||||
                    var fw = WhereObject(table, aliasAndDot, i);
 | 
			
		||||
                    if (string.IsNullOrEmpty(fw)) continue;
 | 
			
		||||
                    if (ieidx > 0) sb.Append(" OR ");
 | 
			
		||||
                    sb.Append(fw);
 | 
			
		||||
                    ++ieidx;
 | 
			
		||||
                }
 | 
			
		||||
                return sb.ToString();
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                var sb = new StringBuilder();
 | 
			
		||||
                var ps = type.GetProperties();
 | 
			
		||||
                var psidx = 0;
 | 
			
		||||
                foreach (var p in ps)
 | 
			
		||||
                {
 | 
			
		||||
                    if (table.Columns.TryGetValue(p.Name, out var trycol) == false) continue;
 | 
			
		||||
                    if (psidx > 0) sb.Append(" AND ");
 | 
			
		||||
                    sb.Append(aliasAndDot).Append(this.QuoteSqlName(trycol.Attribute.Name));
 | 
			
		||||
                    sb.Append(this.FormatSql(" = {0}", Utils.GetDataReaderValue(trycol.Attribute.MapType, p.GetValue(dywhere))));
 | 
			
		||||
                    ++psidx;
 | 
			
		||||
                }
 | 
			
		||||
                if (psidx == 0) return "";
 | 
			
		||||
                return sb.ToString();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		public string WhereItems<TEntity>(TableInfo table, string aliasAndDot, IEnumerable<TEntity> items) {
 | 
			
		||||
			if (items == null || items.Any() == false) return null;
 | 
			
		||||
			if (table.Primarys.Any() == false) return null;
 | 
			
		||||
			var its = items.Where(a => a != null).ToArray();
 | 
			
		||||
        public string WhereItems<TEntity>(TableInfo table, string aliasAndDot, IEnumerable<TEntity> items)
 | 
			
		||||
        {
 | 
			
		||||
            if (items == null || items.Any() == false) return null;
 | 
			
		||||
            if (table.Primarys.Any() == false) return null;
 | 
			
		||||
            var its = items.Where(a => a != null).ToArray();
 | 
			
		||||
 | 
			
		||||
			var pk1 = table.Primarys.FirstOrDefault();
 | 
			
		||||
			if (table.Primarys.Length == 1) {
 | 
			
		||||
				var sbin = new StringBuilder();
 | 
			
		||||
				sbin.Append(aliasAndDot).Append(this.QuoteSqlName(pk1.Attribute.Name));
 | 
			
		||||
				var indt = its.Select(a => pk1.GetMapValue(a)).Where(a => a != null).ToArray();
 | 
			
		||||
				if (indt.Any() == false) return null;
 | 
			
		||||
				if (indt.Length == 1) sbin.Append(" = ").Append(this.FormatSql("{0}", indt.First()));
 | 
			
		||||
				else sbin.Append(" IN (").Append(string.Join(",", indt.Select(a => this.FormatSql("{0}", a)))).Append(")");
 | 
			
		||||
				return sbin.ToString();
 | 
			
		||||
			}
 | 
			
		||||
			var dicpk = its.Length > 5 ? new Dictionary<string, bool>() : null;
 | 
			
		||||
			var sb = its.Length > 5 ? null : new StringBuilder();
 | 
			
		||||
			var iidx = 0;
 | 
			
		||||
			foreach (var item in its) {
 | 
			
		||||
				var filter = "";
 | 
			
		||||
				foreach (var pk in table.Primarys)
 | 
			
		||||
					filter += $" AND {aliasAndDot}{this.QuoteSqlName(pk.Attribute.Name)} = {this.FormatSql("{0}", pk.GetMapValue(item))}";
 | 
			
		||||
				if (string.IsNullOrEmpty(filter)) continue;
 | 
			
		||||
				if (sb != null) {
 | 
			
		||||
					sb.Append(" OR (");
 | 
			
		||||
					sb.Append(filter.Substring(5));
 | 
			
		||||
					sb.Append(")");
 | 
			
		||||
					++iidx;
 | 
			
		||||
				}
 | 
			
		||||
				if (dicpk != null) {
 | 
			
		||||
					filter = filter.Substring(5);
 | 
			
		||||
					if (dicpk.ContainsKey(filter) == false) {
 | 
			
		||||
						dicpk.Add(filter, true);
 | 
			
		||||
						++iidx;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				//++iidx;
 | 
			
		||||
			}
 | 
			
		||||
			if (iidx == 0) return null;
 | 
			
		||||
			if (sb == null) {
 | 
			
		||||
				sb = new StringBuilder();
 | 
			
		||||
				foreach (var fil in dicpk) {
 | 
			
		||||
					sb.Append(" OR (");
 | 
			
		||||
					sb.Append(fil.Key);
 | 
			
		||||
					sb.Append(")");
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			return iidx == 1 ? sb.Remove(0, 5).Remove(sb.Length - 1, 1).ToString() : sb.Remove(0, 4).ToString();
 | 
			
		||||
		}
 | 
			
		||||
            var pk1 = table.Primarys.FirstOrDefault();
 | 
			
		||||
            if (table.Primarys.Length == 1)
 | 
			
		||||
            {
 | 
			
		||||
                var sbin = new StringBuilder();
 | 
			
		||||
                sbin.Append(aliasAndDot).Append(this.QuoteSqlName(pk1.Attribute.Name));
 | 
			
		||||
                var indt = its.Select(a => pk1.GetMapValue(a)).Where(a => a != null).ToArray();
 | 
			
		||||
                if (indt.Any() == false) return null;
 | 
			
		||||
                if (indt.Length == 1) sbin.Append(" = ").Append(this.FormatSql("{0}", indt.First()));
 | 
			
		||||
                else sbin.Append(" IN (").Append(string.Join(",", indt.Select(a => this.FormatSql("{0}", a)))).Append(")");
 | 
			
		||||
                return sbin.ToString();
 | 
			
		||||
            }
 | 
			
		||||
            var dicpk = its.Length > 5 ? new Dictionary<string, bool>() : null;
 | 
			
		||||
            var sb = its.Length > 5 ? null : new StringBuilder();
 | 
			
		||||
            var iidx = 0;
 | 
			
		||||
            foreach (var item in its)
 | 
			
		||||
            {
 | 
			
		||||
                var filter = "";
 | 
			
		||||
                foreach (var pk in table.Primarys)
 | 
			
		||||
                    filter += $" AND {aliasAndDot}{this.QuoteSqlName(pk.Attribute.Name)} = {this.FormatSql("{0}", pk.GetMapValue(item))}";
 | 
			
		||||
                if (string.IsNullOrEmpty(filter)) continue;
 | 
			
		||||
                if (sb != null)
 | 
			
		||||
                {
 | 
			
		||||
                    sb.Append(" OR (");
 | 
			
		||||
                    sb.Append(filter.Substring(5));
 | 
			
		||||
                    sb.Append(")");
 | 
			
		||||
                    ++iidx;
 | 
			
		||||
                }
 | 
			
		||||
                if (dicpk != null)
 | 
			
		||||
                {
 | 
			
		||||
                    filter = filter.Substring(5);
 | 
			
		||||
                    if (dicpk.ContainsKey(filter) == false)
 | 
			
		||||
                    {
 | 
			
		||||
                        dicpk.Add(filter, true);
 | 
			
		||||
                        ++iidx;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                //++iidx;
 | 
			
		||||
            }
 | 
			
		||||
            if (iidx == 0) return null;
 | 
			
		||||
            if (sb == null)
 | 
			
		||||
            {
 | 
			
		||||
                sb = new StringBuilder();
 | 
			
		||||
                foreach (var fil in dicpk)
 | 
			
		||||
                {
 | 
			
		||||
                    sb.Append(" OR (");
 | 
			
		||||
                    sb.Append(fil.Key);
 | 
			
		||||
                    sb.Append(")");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return iidx == 1 ? sb.Remove(0, 5).Remove(sb.Length - 1, 1).ToString() : sb.Remove(0, 4).ToString();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		/// <summary>
 | 
			
		||||
		/// 通过属性的注释文本,通过 xml 读取
 | 
			
		||||
		/// </summary>
 | 
			
		||||
		/// <param name="type"></param>
 | 
			
		||||
		/// <returns>Dict:key=属性名,value=注释</returns>
 | 
			
		||||
		public static Dictionary<string, string> GetProperyCommentBySummary(Type type) {
 | 
			
		||||
			var xmlPath = type.Assembly.Location.Replace(".dll", ".xml");
 | 
			
		||||
			if (File.Exists(xmlPath) == false) return null;
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 通过属性的注释文本,通过 xml 读取
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="type"></param>
 | 
			
		||||
        /// <returns>Dict:key=属性名,value=注释</returns>
 | 
			
		||||
        public static Dictionary<string, string> GetProperyCommentBySummary(Type type)
 | 
			
		||||
        {
 | 
			
		||||
            var xmlPath = type.Assembly.Location.Replace(".dll", ".xml");
 | 
			
		||||
            if (File.Exists(xmlPath) == false) return null;
 | 
			
		||||
 | 
			
		||||
			var dic = new Dictionary<string, string>();
 | 
			
		||||
			var className = type.IsNested ? $"{type.Namespace}.{type.DeclaringType.Name}.{type.Name}" : $"{type.Namespace}.{type.Name}";
 | 
			
		||||
			var sReader = new StringReader(File.ReadAllText(xmlPath));
 | 
			
		||||
			using (var xmlReader = XmlReader.Create(sReader)) {
 | 
			
		||||
				var xpath = new XPathDocument(xmlReader);
 | 
			
		||||
				var xmlNav = xpath.CreateNavigator();
 | 
			
		||||
            var dic = new Dictionary<string, string>();
 | 
			
		||||
            var className = type.IsNested ? $"{type.Namespace}.{type.DeclaringType.Name}.{type.Name}" : $"{type.Namespace}.{type.Name}";
 | 
			
		||||
            var sReader = new StringReader(File.ReadAllText(xmlPath));
 | 
			
		||||
            using (var xmlReader = XmlReader.Create(sReader))
 | 
			
		||||
            {
 | 
			
		||||
                var xpath = new XPathDocument(xmlReader);
 | 
			
		||||
                var xmlNav = xpath.CreateNavigator();
 | 
			
		||||
 | 
			
		||||
				var props = type.GetProperties();
 | 
			
		||||
				foreach (var prop in props) {
 | 
			
		||||
					var node = xmlNav.SelectSingleNode($"/doc/members/member[@name='P:{className}.{prop.Name}']/summary");
 | 
			
		||||
					if (node == null) continue;
 | 
			
		||||
					var comment = node.InnerXml.Trim(' ', '\r', '\n', '\t');
 | 
			
		||||
					if (string.IsNullOrEmpty(comment)) continue;
 | 
			
		||||
                var props = type.GetProperties();
 | 
			
		||||
                foreach (var prop in props)
 | 
			
		||||
                {
 | 
			
		||||
                    var node = xmlNav.SelectSingleNode($"/doc/members/member[@name='P:{className}.{prop.Name}']/summary");
 | 
			
		||||
                    if (node == null) continue;
 | 
			
		||||
                    var comment = node.InnerXml.Trim(' ', '\r', '\n', '\t');
 | 
			
		||||
                    if (string.IsNullOrEmpty(comment)) continue;
 | 
			
		||||
 | 
			
		||||
					dic.Add(prop.Name, comment);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
                    dic.Add(prop.Name, comment);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
			return dic;
 | 
			
		||||
		}
 | 
			
		||||
            return dic;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		public static void PrevReheatConnectionPool(ObjectPool<DbConnection> pool, int minPoolSize) {
 | 
			
		||||
			if (minPoolSize <= 0) minPoolSize = Math.Min(5, pool.Policy.PoolSize);
 | 
			
		||||
			if (minPoolSize > pool.Policy.PoolSize) minPoolSize = pool.Policy.PoolSize;
 | 
			
		||||
			var initTestOk = true;
 | 
			
		||||
			var initStartTime = DateTime.Now;
 | 
			
		||||
			var initConns = new ConcurrentBag<Object<DbConnection>>();
 | 
			
		||||
        public static void PrevReheatConnectionPool(ObjectPool<DbConnection> pool, int minPoolSize)
 | 
			
		||||
        {
 | 
			
		||||
            if (minPoolSize <= 0) minPoolSize = Math.Min(5, pool.Policy.PoolSize);
 | 
			
		||||
            if (minPoolSize > pool.Policy.PoolSize) minPoolSize = pool.Policy.PoolSize;
 | 
			
		||||
            var initTestOk = true;
 | 
			
		||||
            var initStartTime = DateTime.Now;
 | 
			
		||||
            var initConns = new ConcurrentBag<Object<DbConnection>>();
 | 
			
		||||
 | 
			
		||||
			try {
 | 
			
		||||
				var conn = pool.Get();
 | 
			
		||||
				initConns.Add(conn);
 | 
			
		||||
				pool.Policy.OnCheckAvailable(conn);
 | 
			
		||||
			} catch {
 | 
			
		||||
				initTestOk = false; //预热一次失败,后面将不进行
 | 
			
		||||
			}
 | 
			
		||||
			for (var a = 1; initTestOk && a < minPoolSize; a += 10) {
 | 
			
		||||
				if (initStartTime.Subtract(DateTime.Now).TotalSeconds > 3) break; //预热耗时超过3秒,退出
 | 
			
		||||
				var b = Math.Min(minPoolSize - a, 10); //每10个预热
 | 
			
		||||
				var initTasks = new Task[b];
 | 
			
		||||
				for (var c = 0; c < b; c++) {
 | 
			
		||||
					initTasks[c] = Task.Run(() => {
 | 
			
		||||
						try {
 | 
			
		||||
							var conn = pool.Get();
 | 
			
		||||
							initConns.Add(conn);
 | 
			
		||||
							pool.Policy.OnCheckAvailable(conn);
 | 
			
		||||
						} catch {
 | 
			
		||||
							initTestOk = false;  //有失败,下一组退出预热
 | 
			
		||||
						}
 | 
			
		||||
					});
 | 
			
		||||
				}
 | 
			
		||||
				Task.WaitAll(initTasks);
 | 
			
		||||
			}
 | 
			
		||||
			while (initConns.TryTake(out var conn)) pool.Return(conn);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                var conn = pool.Get();
 | 
			
		||||
                initConns.Add(conn);
 | 
			
		||||
                pool.Policy.OnCheckAvailable(conn);
 | 
			
		||||
            }
 | 
			
		||||
            catch
 | 
			
		||||
            {
 | 
			
		||||
                initTestOk = false; //预热一次失败,后面将不进行
 | 
			
		||||
            }
 | 
			
		||||
            for (var a = 1; initTestOk && a < minPoolSize; a += 10)
 | 
			
		||||
            {
 | 
			
		||||
                if (initStartTime.Subtract(DateTime.Now).TotalSeconds > 3) break; //预热耗时超过3秒,退出
 | 
			
		||||
                var b = Math.Min(minPoolSize - a, 10); //每10个预热
 | 
			
		||||
                var initTasks = new Task[b];
 | 
			
		||||
                for (var c = 0; c < b; c++)
 | 
			
		||||
                {
 | 
			
		||||
                    initTasks[c] = Task.Run(() =>
 | 
			
		||||
                    {
 | 
			
		||||
                        try
 | 
			
		||||
                        {
 | 
			
		||||
                            var conn = pool.Get();
 | 
			
		||||
                            initConns.Add(conn);
 | 
			
		||||
                            pool.Policy.OnCheckAvailable(conn);
 | 
			
		||||
                        }
 | 
			
		||||
                        catch
 | 
			
		||||
                        {
 | 
			
		||||
                            initTestOk = false;  //有失败,下一组退出预热
 | 
			
		||||
                        }
 | 
			
		||||
                    });
 | 
			
		||||
                }
 | 
			
		||||
                Task.WaitAll(initTasks);
 | 
			
		||||
            }
 | 
			
		||||
            while (initConns.TryTake(out var conn)) pool.Return(conn);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,71 +4,77 @@ using System.Collections.Concurrent;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.Model {
 | 
			
		||||
	public class ColumnInfo {
 | 
			
		||||
		public TableInfo Table { get; set; }
 | 
			
		||||
		public string CsName { get; set; }
 | 
			
		||||
		public Type CsType { get; set; }
 | 
			
		||||
		public ColumnAttribute Attribute { get; set; }
 | 
			
		||||
		public string Comment { get; internal set; }
 | 
			
		||||
namespace FreeSql.Internal.Model
 | 
			
		||||
{
 | 
			
		||||
    public class ColumnInfo
 | 
			
		||||
    {
 | 
			
		||||
        public TableInfo Table { get; set; }
 | 
			
		||||
        public string CsName { get; set; }
 | 
			
		||||
        public Type CsType { get; set; }
 | 
			
		||||
        public ColumnAttribute Attribute { get; set; }
 | 
			
		||||
        public string Comment { get; internal set; }
 | 
			
		||||
 | 
			
		||||
		static ConcurrentDictionary<ColumnInfo, Func<object, object>> _dicGetMapValue = new ConcurrentDictionary<ColumnInfo, Func<object, object>>();
 | 
			
		||||
		public object GetMapValue(object obj) {
 | 
			
		||||
			var func = _dicGetMapValue.GetOrAdd(this, col => {
 | 
			
		||||
				var paramExp = Expression.Parameter(typeof(object));
 | 
			
		||||
				var returnTarget = Expression.Label(typeof(object));
 | 
			
		||||
        static ConcurrentDictionary<ColumnInfo, Func<object, object>> _dicGetMapValue = new ConcurrentDictionary<ColumnInfo, Func<object, object>>();
 | 
			
		||||
        public object GetMapValue(object obj)
 | 
			
		||||
        {
 | 
			
		||||
            var func = _dicGetMapValue.GetOrAdd(this, col =>
 | 
			
		||||
            {
 | 
			
		||||
                var paramExp = Expression.Parameter(typeof(object));
 | 
			
		||||
                var returnTarget = Expression.Label(typeof(object));
 | 
			
		||||
 | 
			
		||||
				if (Attribute.MapType == CsType)
 | 
			
		||||
					return Expression.Lambda<Func<object, object>>(
 | 
			
		||||
						Expression.Block(
 | 
			
		||||
							Expression.Return(returnTarget, Expression.Convert(
 | 
			
		||||
								Expression.MakeMemberAccess(
 | 
			
		||||
									Expression.TypeAs(paramExp, col.Table.Type),
 | 
			
		||||
									Table.Properties[col.CsName]
 | 
			
		||||
								), typeof(object))),
 | 
			
		||||
							Expression.Label(returnTarget, Expression.Default(typeof(object)))
 | 
			
		||||
						), new[] { paramExp }).Compile();
 | 
			
		||||
                if (Attribute.MapType == CsType)
 | 
			
		||||
                    return Expression.Lambda<Func<object, object>>(
 | 
			
		||||
                        Expression.Block(
 | 
			
		||||
                            Expression.Return(returnTarget, Expression.Convert(
 | 
			
		||||
                                Expression.MakeMemberAccess(
 | 
			
		||||
                                    Expression.TypeAs(paramExp, col.Table.Type),
 | 
			
		||||
                                    Table.Properties[col.CsName]
 | 
			
		||||
                                ), typeof(object))),
 | 
			
		||||
                            Expression.Label(returnTarget, Expression.Default(typeof(object)))
 | 
			
		||||
                        ), new[] { paramExp }).Compile();
 | 
			
		||||
 | 
			
		||||
				var retExp = Expression.Variable(typeof(object), "ret");
 | 
			
		||||
				var blockExp = new List<Expression>();
 | 
			
		||||
				blockExp.AddRange(new Expression[] {
 | 
			
		||||
					Expression.Assign(retExp, Utils.GetDataReaderValueBlockExpression(Attribute.MapType,
 | 
			
		||||
						Expression.MakeMemberAccess(
 | 
			
		||||
							Expression.TypeAs(paramExp, col.Table.Type),
 | 
			
		||||
							Table.Properties[col.CsName]
 | 
			
		||||
						)
 | 
			
		||||
					)),
 | 
			
		||||
					Expression.Return(returnTarget, retExp),
 | 
			
		||||
					Expression.Label(returnTarget, Expression.Default(typeof(object)))
 | 
			
		||||
				});
 | 
			
		||||
				return Expression.Lambda<Func<object, object>>(Expression.Block(new[] { retExp }, blockExp), new[] { paramExp }).Compile();
 | 
			
		||||
			});
 | 
			
		||||
			return func(obj);
 | 
			
		||||
		}
 | 
			
		||||
		static ConcurrentDictionary<ColumnInfo, Action<object, object>> _dicSetMapValue = new ConcurrentDictionary<ColumnInfo, Action<object, object>>();
 | 
			
		||||
		public void SetMapValue(object obj, object val) {
 | 
			
		||||
			var func = _dicSetMapValue.GetOrAdd(this, col => {
 | 
			
		||||
				var objExp = Expression.Parameter(typeof(object), "obj");
 | 
			
		||||
				var valExp = Expression.Parameter(typeof(object), "val");
 | 
			
		||||
                var retExp = Expression.Variable(typeof(object), "ret");
 | 
			
		||||
                var blockExp = new List<Expression>();
 | 
			
		||||
                blockExp.AddRange(new Expression[] {
 | 
			
		||||
                    Expression.Assign(retExp, Utils.GetDataReaderValueBlockExpression(Attribute.MapType,
 | 
			
		||||
                        Expression.MakeMemberAccess(
 | 
			
		||||
                            Expression.TypeAs(paramExp, col.Table.Type),
 | 
			
		||||
                            Table.Properties[col.CsName]
 | 
			
		||||
                        )
 | 
			
		||||
                    )),
 | 
			
		||||
                    Expression.Return(returnTarget, retExp),
 | 
			
		||||
                    Expression.Label(returnTarget, Expression.Default(typeof(object)))
 | 
			
		||||
                });
 | 
			
		||||
                return Expression.Lambda<Func<object, object>>(Expression.Block(new[] { retExp }, blockExp), new[] { paramExp }).Compile();
 | 
			
		||||
            });
 | 
			
		||||
            return func(obj);
 | 
			
		||||
        }
 | 
			
		||||
        static ConcurrentDictionary<ColumnInfo, Action<object, object>> _dicSetMapValue = new ConcurrentDictionary<ColumnInfo, Action<object, object>>();
 | 
			
		||||
        public void SetMapValue(object obj, object val)
 | 
			
		||||
        {
 | 
			
		||||
            var func = _dicSetMapValue.GetOrAdd(this, col =>
 | 
			
		||||
            {
 | 
			
		||||
                var objExp = Expression.Parameter(typeof(object), "obj");
 | 
			
		||||
                var valExp = Expression.Parameter(typeof(object), "val");
 | 
			
		||||
 | 
			
		||||
				if (Attribute.MapType == CsType)
 | 
			
		||||
					return Expression.Lambda<Action<object, object>>(
 | 
			
		||||
						Expression.Assign(Expression.MakeMemberAccess(
 | 
			
		||||
							Expression.TypeAs(objExp, col.Table.Type),
 | 
			
		||||
							Table.Properties[col.CsName]
 | 
			
		||||
						), Expression.Convert(
 | 
			
		||||
							valExp, 
 | 
			
		||||
							Attribute.MapType)), objExp, valExp).Compile();
 | 
			
		||||
                if (Attribute.MapType == CsType)
 | 
			
		||||
                    return Expression.Lambda<Action<object, object>>(
 | 
			
		||||
                        Expression.Assign(Expression.MakeMemberAccess(
 | 
			
		||||
                            Expression.TypeAs(objExp, col.Table.Type),
 | 
			
		||||
                            Table.Properties[col.CsName]
 | 
			
		||||
                        ), Expression.Convert(
 | 
			
		||||
                            valExp,
 | 
			
		||||
                            Attribute.MapType)), objExp, valExp).Compile();
 | 
			
		||||
 | 
			
		||||
				return Expression.Lambda<Action<object, object>>(
 | 
			
		||||
					Expression.Assign(Expression.MakeMemberAccess(
 | 
			
		||||
						Expression.TypeAs(objExp, col.Table.Type),
 | 
			
		||||
						Table.Properties[col.CsName]
 | 
			
		||||
					), Expression.Convert(
 | 
			
		||||
						Utils.GetDataReaderValueBlockExpression(Attribute.MapType, valExp), 
 | 
			
		||||
						Attribute.MapType)), objExp, valExp).Compile();
 | 
			
		||||
			});
 | 
			
		||||
			func(obj, val);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
                return Expression.Lambda<Action<object, object>>(
 | 
			
		||||
                    Expression.Assign(Expression.MakeMemberAccess(
 | 
			
		||||
                        Expression.TypeAs(objExp, col.Table.Type),
 | 
			
		||||
                        Table.Properties[col.CsName]
 | 
			
		||||
                    ), Expression.Convert(
 | 
			
		||||
                        Utils.GetDataReaderValueBlockExpression(Attribute.MapType, valExp),
 | 
			
		||||
                        Attribute.MapType)), objExp, valExp).Compile();
 | 
			
		||||
            });
 | 
			
		||||
            func(obj, val);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -3,17 +3,19 @@ using System.Collections.Generic;
 | 
			
		||||
using System.Reflection;
 | 
			
		||||
using System.Text;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.Model {
 | 
			
		||||
	public class ReadAnonymousTypeInfo {
 | 
			
		||||
		public PropertyInfo Property { get; set; }
 | 
			
		||||
		public string CsName { get; set; }
 | 
			
		||||
		public Type CsType { get; set; }
 | 
			
		||||
		public Type MapType { get; set; }
 | 
			
		||||
		public string DbField { get; set; }
 | 
			
		||||
		public ConstructorInfo Consturctor { get; set; }
 | 
			
		||||
		public ReadAnonymousTypeInfoConsturctorType ConsturctorType { get; set; }
 | 
			
		||||
		public List<ReadAnonymousTypeInfo> Childs = new List<ReadAnonymousTypeInfo>();
 | 
			
		||||
		public TableInfo Table { get; set; }
 | 
			
		||||
	}
 | 
			
		||||
	public enum ReadAnonymousTypeInfoConsturctorType { Arguments, Properties }
 | 
			
		||||
namespace FreeSql.Internal.Model
 | 
			
		||||
{
 | 
			
		||||
    public class ReadAnonymousTypeInfo
 | 
			
		||||
    {
 | 
			
		||||
        public PropertyInfo Property { get; set; }
 | 
			
		||||
        public string CsName { get; set; }
 | 
			
		||||
        public Type CsType { get; set; }
 | 
			
		||||
        public Type MapType { get; set; }
 | 
			
		||||
        public string DbField { get; set; }
 | 
			
		||||
        public ConstructorInfo Consturctor { get; set; }
 | 
			
		||||
        public ReadAnonymousTypeInfoConsturctorType ConsturctorType { get; set; }
 | 
			
		||||
        public List<ReadAnonymousTypeInfo> Childs = new List<ReadAnonymousTypeInfo>();
 | 
			
		||||
        public TableInfo Table { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
    public enum ReadAnonymousTypeInfoConsturctorType { Arguments, Properties }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,9 +2,11 @@
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Text;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.Model {
 | 
			
		||||
	public class SelectColumnInfo {
 | 
			
		||||
		public ColumnInfo Column { get; set; }
 | 
			
		||||
		public SelectTableInfo Table { get; set; }
 | 
			
		||||
	}
 | 
			
		||||
namespace FreeSql.Internal.Model
 | 
			
		||||
{
 | 
			
		||||
    public class SelectColumnInfo
 | 
			
		||||
    {
 | 
			
		||||
        public ColumnInfo Column { get; set; }
 | 
			
		||||
        public SelectTableInfo Table { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,22 +1,26 @@
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.Model {
 | 
			
		||||
	public class SelectTableInfo {
 | 
			
		||||
		public TableInfo Table { get; set; }
 | 
			
		||||
namespace FreeSql.Internal.Model
 | 
			
		||||
{
 | 
			
		||||
    public class SelectTableInfo
 | 
			
		||||
    {
 | 
			
		||||
        public TableInfo Table { get; set; }
 | 
			
		||||
 | 
			
		||||
		private string _alias;
 | 
			
		||||
		public string Alias {
 | 
			
		||||
			get => _alias;
 | 
			
		||||
			set {
 | 
			
		||||
				_alias = value;
 | 
			
		||||
				if (string.IsNullOrEmpty(AliasInit)) AliasInit = value;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		public string AliasInit { get; set; }
 | 
			
		||||
		public string On { get; set; }
 | 
			
		||||
		public string NavigateCondition { get; set; }
 | 
			
		||||
		public ParameterExpression Parameter { get; set; }
 | 
			
		||||
		public SelectTableInfoType Type { get; set; }
 | 
			
		||||
	}
 | 
			
		||||
	public enum SelectTableInfoType { From, LeftJoin, InnerJoin, RightJoin, Parent }
 | 
			
		||||
        private string _alias;
 | 
			
		||||
        public string Alias
 | 
			
		||||
        {
 | 
			
		||||
            get => _alias;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                _alias = value;
 | 
			
		||||
                if (string.IsNullOrEmpty(AliasInit)) AliasInit = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        public string AliasInit { get; set; }
 | 
			
		||||
        public string On { get; set; }
 | 
			
		||||
        public string NavigateCondition { get; set; }
 | 
			
		||||
        public ParameterExpression Parameter { get; set; }
 | 
			
		||||
        public SelectTableInfoType Type { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
    public enum SelectTableInfoType { From, LeftJoin, InnerJoin, RightJoin, Parent }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -3,58 +3,65 @@ using System.Collections.Concurrent;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Reflection;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Internal.Model {
 | 
			
		||||
	public class TableInfo {
 | 
			
		||||
		public Type Type { get; set; }
 | 
			
		||||
		public Type TypeLazy { get; set; }
 | 
			
		||||
		public MethodInfo TypeLazySetOrm { get; set; }
 | 
			
		||||
		public Dictionary<string, PropertyInfo> Properties { get; set; } = new Dictionary<string, PropertyInfo>(StringComparer.CurrentCultureIgnoreCase);
 | 
			
		||||
		public Dictionary<string, ColumnInfo> Columns { get; set; } = new Dictionary<string, ColumnInfo>(StringComparer.CurrentCultureIgnoreCase);
 | 
			
		||||
		public Dictionary<string, ColumnInfo> ColumnsByCs { get; set; } = new Dictionary<string, ColumnInfo>(StringComparer.CurrentCultureIgnoreCase);
 | 
			
		||||
		public Dictionary<string, ColumnInfo> ColumnsByCsIgnore { get; set; } = new Dictionary<string, ColumnInfo>(StringComparer.CurrentCultureIgnoreCase);
 | 
			
		||||
		public ColumnInfo[] Primarys { get; set; }
 | 
			
		||||
		public Dictionary<string, List<ColumnInfo>> Uniques { get; set; }
 | 
			
		||||
		public string CsName { get; set; }
 | 
			
		||||
		public string DbName { get; set; }
 | 
			
		||||
		public string DbOldName { get; set; }
 | 
			
		||||
		public string SelectFilter { get; set; }
 | 
			
		||||
		public bool DisableSyncStructure { get; set; }
 | 
			
		||||
namespace FreeSql.Internal.Model
 | 
			
		||||
{
 | 
			
		||||
    public class TableInfo
 | 
			
		||||
    {
 | 
			
		||||
        public Type Type { get; set; }
 | 
			
		||||
        public Type TypeLazy { get; set; }
 | 
			
		||||
        public MethodInfo TypeLazySetOrm { get; set; }
 | 
			
		||||
        public Dictionary<string, PropertyInfo> Properties { get; set; } = new Dictionary<string, PropertyInfo>(StringComparer.CurrentCultureIgnoreCase);
 | 
			
		||||
        public Dictionary<string, ColumnInfo> Columns { get; set; } = new Dictionary<string, ColumnInfo>(StringComparer.CurrentCultureIgnoreCase);
 | 
			
		||||
        public Dictionary<string, ColumnInfo> ColumnsByCs { get; set; } = new Dictionary<string, ColumnInfo>(StringComparer.CurrentCultureIgnoreCase);
 | 
			
		||||
        public Dictionary<string, ColumnInfo> ColumnsByCsIgnore { get; set; } = new Dictionary<string, ColumnInfo>(StringComparer.CurrentCultureIgnoreCase);
 | 
			
		||||
        public ColumnInfo[] Primarys { get; set; }
 | 
			
		||||
        public Dictionary<string, List<ColumnInfo>> Uniques { get; set; }
 | 
			
		||||
        public string CsName { get; set; }
 | 
			
		||||
        public string DbName { get; set; }
 | 
			
		||||
        public string DbOldName { get; set; }
 | 
			
		||||
        public string SelectFilter { get; set; }
 | 
			
		||||
        public bool DisableSyncStructure { get; set; }
 | 
			
		||||
 | 
			
		||||
		public ColumnInfo VersionColumn { get; set; }
 | 
			
		||||
        public ColumnInfo VersionColumn { get; set; }
 | 
			
		||||
 | 
			
		||||
		ConcurrentDictionary<string, TableRef> _refs { get; } = new ConcurrentDictionary<string, TableRef>(StringComparer.CurrentCultureIgnoreCase);
 | 
			
		||||
        ConcurrentDictionary<string, TableRef> _refs { get; } = new ConcurrentDictionary<string, TableRef>(StringComparer.CurrentCultureIgnoreCase);
 | 
			
		||||
 | 
			
		||||
		internal void AddOrUpdateTableRef(string propertyName, TableRef tbref) {
 | 
			
		||||
			_refs.AddOrUpdate(propertyName, tbref, (ok, ov) => tbref);
 | 
			
		||||
		}
 | 
			
		||||
		public TableRef GetTableRef(string propertyName, bool isThrowException) {
 | 
			
		||||
			if (_refs.TryGetValue(propertyName, out var tryref) == false) return null;
 | 
			
		||||
			if (tryref.Exception != null) {
 | 
			
		||||
				if (isThrowException) throw tryref.Exception;
 | 
			
		||||
				return null;
 | 
			
		||||
			}
 | 
			
		||||
			return tryref;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
        internal void AddOrUpdateTableRef(string propertyName, TableRef tbref)
 | 
			
		||||
        {
 | 
			
		||||
            _refs.AddOrUpdate(propertyName, tbref, (ok, ov) => tbref);
 | 
			
		||||
        }
 | 
			
		||||
        public TableRef GetTableRef(string propertyName, bool isThrowException)
 | 
			
		||||
        {
 | 
			
		||||
            if (_refs.TryGetValue(propertyName, out var tryref) == false) return null;
 | 
			
		||||
            if (tryref.Exception != null)
 | 
			
		||||
            {
 | 
			
		||||
                if (isThrowException) throw tryref.Exception;
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            return tryref;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	public class TableRef {
 | 
			
		||||
		public PropertyInfo Property { get; set; }
 | 
			
		||||
    public class TableRef
 | 
			
		||||
    {
 | 
			
		||||
        public PropertyInfo Property { get; set; }
 | 
			
		||||
 | 
			
		||||
		public TableRefType RefType { get; set; }
 | 
			
		||||
        public TableRefType RefType { get; set; }
 | 
			
		||||
 | 
			
		||||
		public Type RefEntityType { get; set; }
 | 
			
		||||
		/// <summary>
 | 
			
		||||
		/// 中间表,多对多
 | 
			
		||||
		/// </summary>
 | 
			
		||||
		public Type RefMiddleEntityType { get; set; }
 | 
			
		||||
        public Type RefEntityType { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 中间表,多对多
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Type RefMiddleEntityType { get; set; }
 | 
			
		||||
 | 
			
		||||
		public List<ColumnInfo> Columns { get; set; } = new List<ColumnInfo>();
 | 
			
		||||
		public List<ColumnInfo> MiddleColumns { get; set; } = new List<ColumnInfo>();
 | 
			
		||||
		public List<ColumnInfo> RefColumns { get; set; } = new List<ColumnInfo>();
 | 
			
		||||
        public List<ColumnInfo> Columns { get; set; } = new List<ColumnInfo>();
 | 
			
		||||
        public List<ColumnInfo> MiddleColumns { get; set; } = new List<ColumnInfo>();
 | 
			
		||||
        public List<ColumnInfo> RefColumns { get; set; } = new List<ColumnInfo>();
 | 
			
		||||
 | 
			
		||||
		public Exception Exception { get; set; }
 | 
			
		||||
	}
 | 
			
		||||
	public enum TableRefType {
 | 
			
		||||
		OneToOne, ManyToOne, OneToMany, ManyToMany
 | 
			
		||||
	}
 | 
			
		||||
        public Exception Exception { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
    public enum TableRefType
 | 
			
		||||
    {
 | 
			
		||||
        OneToOne, ManyToOne, OneToMany, ManyToMany
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user