mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 10:42:52 +08:00
内部微调
This commit is contained in:
parent
d22bed3494
commit
71a0552871
@ -45,12 +45,12 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
public abstract string GetComparisonDDLStatements(params Type[] entityTypes);
|
public abstract string GetComparisonDDLStatements(params Type[] entityTypes);
|
||||||
|
|
||||||
static object syncStructureLock = new object();
|
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<TEntity>() => this.SyncStructure(typeof(TEntity));
|
||||||
public bool SyncStructure(params Type[] entityTypes)
|
public bool SyncStructure(params Type[] entityTypes)
|
||||||
{
|
{
|
||||||
if (entityTypes == null) return false;
|
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;
|
if (syncTypes.Any() == false) return false;
|
||||||
var before = new Aop.SyncStructureBeforeEventArgs(entityTypes);
|
var before = new Aop.SyncStructureBeforeEventArgs(entityTypes);
|
||||||
_orm.Aop.SyncStructureBefore?.Invoke(this, before);
|
_orm.Aop.SyncStructureBefore?.Invoke(this, before);
|
||||||
@ -63,11 +63,11 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
ddl = this.GetComparisonDDLStatements(syncTypes);
|
ddl = this.GetComparisonDDLStatements(syncTypes);
|
||||||
if (string.IsNullOrEmpty(ddl))
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
var affrows = _orm.Ado.ExecuteNonQuery(CommandType.Text, ddl);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
if (typeof(TReturn) == typeof(T1)) return this as ISelect<TReturn>;
|
if (typeof(TReturn) == typeof(T1)) return this as ISelect<TReturn>;
|
||||||
_tables[0].Parameter = select.Parameters[0];
|
_tables[0].Parameter = select.Parameters[0];
|
||||||
_selectExpression = select.Body;
|
_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>();
|
var ret = _orm.Select<TReturn>();
|
||||||
Select0Provider<ISelect<T1>, T1>.CopyData(this, ret, null);
|
Select0Provider<ISelect<T1>, T1>.CopyData(this, ret, null);
|
||||||
return ret;
|
return ret;
|
||||||
@ -228,7 +228,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
), SelectTableInfoType.InnerJoin);
|
), SelectTableInfoType.InnerJoin);
|
||||||
if (typeof(TResult) == typeof(T1)) return this as ISelect<TResult>;
|
if (typeof(TResult) == typeof(T1)) return this as ISelect<TResult>;
|
||||||
_selectExpression = resultSelector.Body;
|
_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>;
|
var ret = _orm.Select<TResult>() as Select1Provider<TResult>;
|
||||||
Select0Provider<ISelect<T1>, T1>.CopyData(this, ret, null);
|
Select0Provider<ISelect<T1>, T1>.CopyData(this, ret, null);
|
||||||
return ret;
|
return ret;
|
||||||
@ -243,7 +243,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
), SelectTableInfoType.InnerJoin);
|
), SelectTableInfoType.InnerJoin);
|
||||||
if (typeof(TResult) == typeof(T1)) return this as ISelect<TResult>;
|
if (typeof(TResult) == typeof(T1)) return this as ISelect<TResult>;
|
||||||
_selectExpression = resultSelector.Body;
|
_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>;
|
var ret = _orm.Select<TResult>() as Select1Provider<TResult>;
|
||||||
Select0Provider<ISelect<T1>, T1>.CopyData(this, ret, null);
|
Select0Provider<ISelect<T1>, T1>.CopyData(this, ret, null);
|
||||||
return ret;
|
return ret;
|
||||||
@ -275,7 +275,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
}
|
}
|
||||||
if (typeof(TResult) == typeof(T1)) return this as ISelect<TResult>;
|
if (typeof(TResult) == typeof(T1)) return this as ISelect<TResult>;
|
||||||
_selectExpression = resultSelector.Body;
|
_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>;
|
var ret = _orm.Select<TResult>() as Select1Provider<TResult>;
|
||||||
Select0Provider<ISelect<T1>, T1>.CopyData(this, ret, null);
|
Select0Provider<ISelect<T1>, T1>.CopyData(this, ret, null);
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user