Skip to content

Commit d62b9f8

Browse files
committed
fix(orm-entity): 修复 EntityBase 设计问题
- 统一 Version 默认值从 1 改为 0,保持泛型版本一致 - 添加 where TKey : notnull 约束增强类型安全 - 移除冗余的 [Column] 属性和无用的 using 指令
1 parent 9400ce1 commit d62b9f8

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

GameFrameX.Foundation.Orm.Entity/EntityBase.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
66

77
using System.ComponentModel;
8-
using System.ComponentModel.DataAnnotations.Schema;
98
using GameFrameX.Foundation.Orm.Entity.Filter;
109

1110
namespace GameFrameX.Foundation.Orm.Entity;
@@ -24,7 +23,6 @@ public abstract class EntityBase : EntityBaseId, ISafeDeletedFilter, IVersionedE
2423
/// <summary>
2524
/// 创建时间
2625
/// </summary>
27-
[Column]
2826
[Description("创建时间")]
2927
public virtual long? CreatedTime { get; set; }
3028

@@ -86,7 +84,7 @@ public abstract class EntityBase : EntityBaseId, ISafeDeletedFilter, IVersionedE
8684
/// 版本号(用于乐观锁)
8785
/// </summary>
8886
[Description("版本号(用于乐观锁)")]
89-
public virtual long? Version { get; set; } = 1;
87+
public virtual long? Version { get; set; } = 0;
9088

9189
/// <summary>
9290
/// 是否启用该实体或功能的标识
@@ -103,6 +101,7 @@ public abstract class EntityBase : EntityBaseId, ISafeDeletedFilter, IVersionedE
103101
/// </summary>
104102
/// <typeparam name="TKey">主键类型</typeparam>
105103
public abstract class EntityBase<TKey> : EntityBaseId<TKey>, ISafeDeletedFilter, IVersionedEntity, ISafeEnabledFilter, ISafeCreatedFilter, ISafeUpdateFilter
104+
where TKey : notnull
106105
{
107106
/// <summary>
108107
/// 创建人Id
@@ -113,7 +112,6 @@ public abstract class EntityBase<TKey> : EntityBaseId<TKey>, ISafeDeletedFilter,
113112
/// <summary>
114113
/// 创建时间
115114
/// </summary>
116-
[Column]
117115
[Description("创建时间")]
118116
public virtual long? CreatedTime { get; set; }
119117

0 commit comments

Comments
 (0)