mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 01:05:27 +08:00 
			
		
		
		
	内部微调
This commit is contained in:
		@@ -45,12 +45,12 @@ namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
        public abstract string GetComparisonDDLStatements(params Type[] entityTypes);
 | 
			
		||||
 | 
			
		||||
        static object syncStructureLock = new object();
 | 
			
		||||
        internal ConcurrentDictionary<string, bool> dicSyced = new ConcurrentDictionary<string, bool>();
 | 
			
		||||
        internal ConcurrentDictionary<Type, bool> dicSyced = new ConcurrentDictionary<Type, 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();
 | 
			
		||||
            var syncTypes = entityTypes.Where(a => dicSyced.ContainsKey(a) == false && GetTableByEntity(a)?.DisableSyncStructure == false).ToArray();
 | 
			
		||||
            if (syncTypes.Any() == false) return false;
 | 
			
		||||
            var before = new Aop.SyncStructureBeforeEventArgs(entityTypes);
 | 
			
		||||
            _orm.Aop.SyncStructureBefore?.Invoke(this, before);
 | 
			
		||||
@@ -63,11 +63,11 @@ namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
                    ddl = this.GetComparisonDDLStatements(syncTypes);
 | 
			
		||||
                    if (string.IsNullOrEmpty(ddl))
 | 
			
		||||
                    {
 | 
			
		||||
                        foreach (var syncType in syncTypes) dicSyced.TryAdd(syncType.FullName, true);
 | 
			
		||||
                        foreach (var syncType in syncTypes) dicSyced.TryAdd(syncType, true);
 | 
			
		||||
                        return true;
 | 
			
		||||
                    }
 | 
			
		||||
                    var affrows = _orm.Ado.ExecuteNonQuery(CommandType.Text, ddl);
 | 
			
		||||
                    foreach (var syncType in syncTypes) dicSyced.TryAdd(syncType.FullName, true);
 | 
			
		||||
                    foreach (var syncType in syncTypes) dicSyced.TryAdd(syncType, true);
 | 
			
		||||
                    return true;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -213,7 +213,7 @@ namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
            if (typeof(TReturn) == typeof(T1)) return this as ISelect<TReturn>;
 | 
			
		||||
            _tables[0].Parameter = select.Parameters[0];
 | 
			
		||||
            _selectExpression = select.Body;
 | 
			
		||||
            (_orm.CodeFirst as CodeFirstProvider).dicSyced.TryAdd(typeof(TReturn).FullName, true);
 | 
			
		||||
            (_orm.CodeFirst as CodeFirstProvider).dicSyced.TryAdd(typeof(TReturn), true);
 | 
			
		||||
            var ret = _orm.Select<TReturn>();
 | 
			
		||||
            Select0Provider<ISelect<T1>, T1>.CopyData(this, ret, null);
 | 
			
		||||
            return ret;
 | 
			
		||||
@@ -228,7 +228,7 @@ namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
            ), SelectTableInfoType.InnerJoin);
 | 
			
		||||
            if (typeof(TResult) == typeof(T1)) return this as ISelect<TResult>;
 | 
			
		||||
            _selectExpression = resultSelector.Body;
 | 
			
		||||
            (_orm.CodeFirst as CodeFirstProvider).dicSyced.TryAdd(typeof(TResult).FullName, true);
 | 
			
		||||
            (_orm.CodeFirst as CodeFirstProvider).dicSyced.TryAdd(typeof(TResult), true);
 | 
			
		||||
            var ret = _orm.Select<TResult>() as Select1Provider<TResult>;
 | 
			
		||||
            Select0Provider<ISelect<T1>, T1>.CopyData(this, ret, null);
 | 
			
		||||
            return ret;
 | 
			
		||||
@@ -243,7 +243,7 @@ namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
            ), SelectTableInfoType.InnerJoin);
 | 
			
		||||
            if (typeof(TResult) == typeof(T1)) return this as ISelect<TResult>;
 | 
			
		||||
            _selectExpression = resultSelector.Body;
 | 
			
		||||
            (_orm.CodeFirst as CodeFirstProvider).dicSyced.TryAdd(typeof(TResult).FullName, true);
 | 
			
		||||
            (_orm.CodeFirst as CodeFirstProvider).dicSyced.TryAdd(typeof(TResult), true);
 | 
			
		||||
            var ret = _orm.Select<TResult>() as Select1Provider<TResult>;
 | 
			
		||||
            Select0Provider<ISelect<T1>, T1>.CopyData(this, ret, null);
 | 
			
		||||
            return ret;
 | 
			
		||||
@@ -275,7 +275,7 @@ namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
            }
 | 
			
		||||
            if (typeof(TResult) == typeof(T1)) return this as ISelect<TResult>;
 | 
			
		||||
            _selectExpression = resultSelector.Body;
 | 
			
		||||
            (_orm.CodeFirst as CodeFirstProvider).dicSyced.TryAdd(typeof(TResult).FullName, true);
 | 
			
		||||
            (_orm.CodeFirst as CodeFirstProvider).dicSyced.TryAdd(typeof(TResult), true);
 | 
			
		||||
            var ret = _orm.Select<TResult>() as Select1Provider<TResult>;
 | 
			
		||||
            Select0Provider<ISelect<T1>, T1>.CopyData(this, ret, null);
 | 
			
		||||
            return ret;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user