mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 10:42:52 +08:00
- 增加 ICodeFirst.SyncStructure 强制同步参数 isForceSync;#412
This commit is contained in:
parent
d10816d62c
commit
31a67a990d
@ -130,13 +130,6 @@
|
||||
清空状态数据
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:FreeSql.DbSet`1.RemoveAsync(System.Linq.Expressions.Expression{System.Func{`0,System.Boolean}})">
|
||||
<summary>
|
||||
根据 lambda 条件删除数据
|
||||
</summary>
|
||||
<param name="predicate"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:FreeSql.DbSet`1.Add(`0)">
|
||||
<summary>
|
||||
添加
|
||||
@ -527,14 +520,5 @@
|
||||
<param name="that"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Microsoft.Extensions.DependencyInjection.FreeSqlRepositoryDependencyInjection.AddFreeRepository(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{FreeSql.FluentDataFilter},System.Reflection.Assembly[])">
|
||||
<summary>
|
||||
批量注入 Repository,可以参考代码自行调整
|
||||
</summary>
|
||||
<param name="services"></param>
|
||||
<param name="globalDataFilter"></param>
|
||||
<param name="assemblies"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
|
@ -937,6 +937,8 @@ WHERE (((to_char(a.""ID"")) in (SELECT b.""TITLE""
|
||||
public void AsTable()
|
||||
{
|
||||
g.dameng.CodeFirst.SyncStructure(typeof(Topic), "TB_TOPIC");
|
||||
g.dameng.CodeFirst.SyncStructure(typeof(Topic), "TB_TOPIC");
|
||||
g.dameng.CodeFirst.SyncStructure(typeof(Topic), "TB_TOPIC", isForceSync: true);
|
||||
|
||||
var listt = select.AsTable((a, b) => "(select * from tb_topic where clicks > 10)").Page(1, 10).ToList();
|
||||
|
||||
|
@ -3065,13 +3065,14 @@
|
||||
</summary>
|
||||
<param name="entityTypes"></param>
|
||||
</member>
|
||||
<member name="M:FreeSql.ICodeFirst.SyncStructure(System.Type,System.String)">
|
||||
<member name="M:FreeSql.ICodeFirst.SyncStructure(System.Type,System.String,System.Boolean)">
|
||||
<summary>
|
||||
同步实体类型到数据库(指定表名)<para></para>
|
||||
注意:生产环境中谨慎使用
|
||||
</summary>
|
||||
<param name="entityType">实体类型</param>
|
||||
<param name="tableName">指定表名对比</param>
|
||||
<param name="isForceSync">强制同步结构,无视缓存每次都同步</param>
|
||||
</member>
|
||||
<member name="M:FreeSql.ICodeFirst.GetDbInfo(System.Type)">
|
||||
<summary>
|
||||
|
@ -80,7 +80,8 @@ namespace FreeSql
|
||||
/// </summary>
|
||||
/// <param name="entityType">实体类型</param>
|
||||
/// <param name="tableName">指定表名对比</param>
|
||||
void SyncStructure(Type entityType, string tableName);
|
||||
/// <param name="isForceSync">强制同步结构,无视缓存每次都同步</param>
|
||||
void SyncStructure(Type entityType, string tableName, bool isForceSync = false);
|
||||
|
||||
/// <summary>
|
||||
/// 根据 System.Type 获取数据库信息
|
||||
|
@ -69,7 +69,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
|
||||
static object syncStructureLock = new object();
|
||||
object _dicSycedLock = new object();
|
||||
ConcurrentDictionary<Type, ConcurrentDictionary<string, bool>> _dicSynced = new ConcurrentDictionary<Type, ConcurrentDictionary<string, bool>>();
|
||||
public ConcurrentDictionary<Type, ConcurrentDictionary<string, bool>> _dicSynced = new ConcurrentDictionary<Type, ConcurrentDictionary<string, bool>>();
|
||||
internal ConcurrentDictionary<string, bool> _dicSycedGetOrAdd(Type entityType)
|
||||
{
|
||||
if (_dicSynced.TryGetValue(entityType, out var trydic) == false)
|
||||
@ -85,8 +85,12 @@ namespace FreeSql.Internal.CommonProvider
|
||||
this.SyncStructure(new TypeAndName(typeof(TEntity), ""));
|
||||
public void SyncStructure(params Type[] entityTypes) =>
|
||||
this.SyncStructure(entityTypes?.Distinct().Select(a => new TypeAndName(a, "")).ToArray());
|
||||
public void SyncStructure(Type entityType, string tableName) =>
|
||||
this.SyncStructure(new TypeAndName(entityType, GetTableNameLowerOrUpper(tableName)));
|
||||
public void SyncStructure(Type entityType, string tableName, bool isForceSync)
|
||||
{
|
||||
tableName = GetTableNameLowerOrUpper(tableName);
|
||||
if (isForceSync && _dicSynced.TryGetValue(entityType, out var dic)) dic.TryRemove(tableName, out var old);
|
||||
this.SyncStructure(new TypeAndName(entityType, tableName));
|
||||
}
|
||||
protected void SyncStructure(params TypeAndName[] objects)
|
||||
{
|
||||
if (objects == null) return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user