Skip to content

Commit 74f8700

Browse files
2881028810
authored andcommitted
- 调整 SyncStructure 返回值为 void
1 parent 19ab4da commit 74f8700

File tree

4 files changed

+28
-18
lines changed

4 files changed

+28
-18
lines changed

FreeSql.DbContext/FreeSql.DbContext.xml

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FreeSql/FreeSql.xml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FreeSql/Interface/ICodeFirst.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,18 @@ public interface ICodeFirst
6666
/// 同步实体类型到数据库
6767
/// </summary>
6868
/// <typeparam name="TEntity"></typeparam>
69-
/// <returns></returns>
70-
bool SyncStructure<TEntity>();
69+
void SyncStructure<TEntity>();
7170
/// <summary>
7271
/// 同步实体类型集合到数据库
7372
/// </summary>
7473
/// <param name="entityTypes"></param>
75-
/// <returns></returns>
76-
bool SyncStructure(params Type[] entityTypes);
74+
void SyncStructure(params Type[] entityTypes);
7775
/// <summary>
7876
/// 同步实体类型到数据库(指定表名)
7977
/// </summary>
8078
/// <param name="entityType">实体类型</param>
8179
/// <param name="tableName">指定表名对比</param>
82-
/// <returns></returns>
83-
bool SyncStructure(Type entityType, string tableName);
80+
void SyncStructure(Type entityType, string tableName);
8481

8582
/// <summary>
8683
/// 根据 System.Type 获取数据库信息

FreeSql/Internal/CommonProvider/CodeFirstProvider.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,18 @@ internal ConcurrentDictionary<string, bool> _dicSycedGetOrAdd(Type entityType)
8181
internal void _dicSycedTryAdd(Type entityType, string tableName = null) =>
8282
_dicSycedGetOrAdd(entityType).TryAdd(GetTableNameLowerOrUpper(tableName), true);
8383

84-
public bool SyncStructure<TEntity>() =>
84+
public void SyncStructure<TEntity>() =>
8585
this.SyncStructure(new TypeAndName(typeof(TEntity), ""));
86-
public bool SyncStructure(params Type[] entityTypes) => entityTypes == null ? false :
87-
this.SyncStructure(entityTypes.Distinct().Select(a => new TypeAndName(a, "")).ToArray());
88-
public bool SyncStructure(Type entityType, string tableName) =>
86+
public void SyncStructure(params Type[] entityTypes) =>
87+
this.SyncStructure(entityTypes?.Distinct().Select(a => new TypeAndName(a, "")).ToArray());
88+
public void SyncStructure(Type entityType, string tableName) =>
8989
this.SyncStructure(new TypeAndName(entityType, GetTableNameLowerOrUpper(tableName)));
90-
protected bool SyncStructure(params TypeAndName[] objects)
90+
protected void SyncStructure(params TypeAndName[] objects)
9191
{
92-
if (objects == null) return false;
92+
if (objects == null) return;
9393
var syncObjects = objects.Where(a => _dicSycedGetOrAdd(a.entityType).ContainsKey(GetTableNameLowerOrUpper(a.tableName)) == false && GetTableByEntity(a.entityType)?.DisableSyncStructure == false)
9494
.Select(a => new TypeAndName(a.entityType, GetTableNameLowerOrUpper(a.tableName))).ToArray();
95-
if (syncObjects.Any() == false) return false;
95+
if (syncObjects.Any() == false) return;
9696
var before = new Aop.SyncStructureBeforeEventArgs(syncObjects.Select(a => a.entityType).ToArray());
9797
_orm.Aop.SyncStructureBeforeHandler?.Invoke(this, before);
9898
Exception exception = null;
@@ -105,11 +105,11 @@ protected bool SyncStructure(params TypeAndName[] objects)
105105
if (string.IsNullOrEmpty(ddl))
106106
{
107107
foreach (var syncObject in syncObjects) _dicSycedTryAdd(syncObject.entityType, syncObject.tableName);
108-
return true;
108+
return;
109109
}
110110
var affrows = ExecuteDDLStatements(ddl);
111111
foreach (var syncObject in syncObjects) _dicSycedTryAdd(syncObject.entityType, syncObject.tableName);
112-
return true;
112+
return;
113113
}
114114
}
115115
catch (Exception ex)

0 commit comments

Comments
 (0)