Skip to content

Commit 8752ea7

Browse files
committed
refactor(orm-entity): 添加泛型 notnull 约束增强类型安全
- EntityBaseId<TKey> 添加 where TKey : notnull - EntityTenantBase<TKey> 添加 where TKey : notnull - 防止可空类型作为主键导致的运行时问题
1 parent d62b9f8 commit 8752ea7

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

GameFrameX.Foundation.Orm.Entity/EntityBaseId.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public abstract class EntityBaseId : IEntity<long>
2222
/// </summary>
2323
/// <typeparam name="TKey">主键类型</typeparam>
2424
public abstract class EntityBaseId<TKey> : IEntity<TKey>
25+
where TKey : notnull
2526
{
2627
/// <summary>
2728
/// 主键Id

GameFrameX.Foundation.Orm.Entity/EntityTenantBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public abstract class EntityTenantBase : EntityBase, ITenantIdFilter
2525
/// </summary>
2626
/// <typeparam name="TKey">主键类型</typeparam>
2727
public abstract class EntityTenantBase<TKey> : EntityBase<TKey>, ITenantIdFilter
28+
where TKey : notnull
2829
{
2930
/// <summary>
3031
/// 租户Id

0 commit comments

Comments
 (0)