private SqlSugarProvider GetContext()
        {
            SqlSugarProvider result = null;

            if (IsSameThreadAndShard())
            {
                result = SameThreadAndShard();
            }
            else if (IsNoSameThreadAndShard())
            {
                result = NoSameThreadAndShard();
            }
            else if (IsSynchronization())
            {
                result = Synchronization();
            }
            else if (IsSingleInstanceAsync())
            {
                result = Synchronization();//Async no support  Single Instance
            }
            else if (IsAsync())
            {
                result = Synchronization();
            }
            else
            {
                IsSingleInstance = true;
                result           = NoSameThread();
            }
            if (result.Root == null)
            {
                result.Root = this;
            }
            return(result);
        }
        private void InitContext(ConnectionConfig config)
        {
            var aopIsNull = config.AopEvents == null;

            if (aopIsNull)
            {
                config.AopEvents = new AopEvents();
            }
            _Context = new SqlSugarProvider(config);
            if (!aopIsNull)
            {
                _Context.Ado.IsEnableLogEvent = true;
            }
            this.CurrentConnectionConfig = config;
            _ThreadId = Thread.CurrentThread.ManagedThreadId.ToString();
            if (_MappingColumns == null)
            {
                this.MappingTables = new MappingTableList();
            }
            if (this.MappingColumns == null)
            {
                this.MappingColumns = new MappingColumnList();
            }
            if (this.IgnoreColumns == null)
            {
                this.IgnoreColumns = new IgnoreColumnList();
            }
            if (this.IgnoreInsertColumns == null)
            {
                this.IgnoreInsertColumns = new IgnoreColumnList();
            }
        }
 internal SaveableProvider(SqlSugarProvider context, T saveObject)
 {
     this.saveObjects = new List <T>()
     {
         saveObject
     };
     this.Context = context;
     this.Context.InitMappingInfo <T>();
 }
        public static CacheKey GetKey(SqlSugarProvider context, QueryBuilder queryBuilder)
        {
            CacheKey result = new CacheKey();

            result.Database = context.Context.Ado.Connection.Database;
            AddTables(context, queryBuilder, result);
            AddIdentificationList(queryBuilder, result);
            return(result);
        }
        private SqlSugarProvider CopyClient()
        {
            var result = new SqlSugarProvider(this.CurrentConnectionConfig);

            result.MappingColumns      = _MappingColumns;
            result.MappingTables       = _MappingTables;
            result.IgnoreColumns       = _IgnoreColumns;
            result.IgnoreInsertColumns = _IgnoreInsertColumns;

            return(result);
        }
 private void AddCallContext(SqlSugarProvider context)
 {
     CallContext.ContextList.Value = new List <SqlSugarProvider>();
     CallContext.ContextList.Value.Add(context);
 }
 internal SaveableProvider(SqlSugarProvider context, List <T> saveObjects)
 {
     this.saveObjects = saveObjects;
     this.Context     = context;
     this.Context.InitMappingInfo <T>();
 }