Skip to content
Promote Your Product

Table Entity

Inheriting Entities

Primary Key Entity

Inherit Entity when a primary key Id is needed

cs
/// <summary>
/// Module
/// </summary>
[Table(Name = "app_module")]
public class ModuleEntity : Entity
{
}

Property description

PropertyDescriptionType
IdPrimary key Id, default snowflake Idlong

Create Entity

Inherit EntityAdd when creation information is needed

cs
/// <summary>
/// Module
/// </summary>
[Table(Name = "app_module")]
public class ModuleEntity : EntityAdd
{
}

Property description

PropertyDescriptionType
IdPrimary key Id, default snowflake Idlong
CreatedUserIdCreator Id, not modifiablelong?
CreatedUserNameCreator, length 50, not modifiablestring
CreatedUserRealNameCreator name, length 50, not modifiablestring
CreatedTimeCreation time, not modifiableDateTime?

Note

When the create entity doesn't need a primary key Id, inherit EntityAddNoId

Update Entity

Inherit EntityUpdate when modification and creation information is needed

cs
/// <summary>
/// Module
/// </summary>
[Table(Name = "app_module")]
public class ModuleEntity : EntityUpdate
{
}

Property description

PropertyDescriptionType
IdPrimary key Id, default snowflake Idlong
CreatedUserIdCreator Id, not modifiablelong?
CreatedUserNameCreator, length 50, not modifiablestring
CreatedUserRealNameCreator name, length 50, not modifiablestring
CreatedTimeCreation time, not modifiableDateTime?
ModifiedUserIdModifier Idlong?
ModifiedUserNameModifier, length 50string
ModifiedUserRealNameModifier name, length 50string
ModifiedTimeModification timeDateTime?

Note

When the update entity doesn't need a primary key Id, inherit EntityUpdateNoId

Delete Entity

Inherit EntityDelete when soft delete, modification, and creation information is needed

cs
/// <summary>
/// Module
/// </summary>
[Table(Name = "app_module")]
public class ModuleEntity : EntityDelete
{
}

Property description

PropertyDescriptionType
IdPrimary key Id, default snowflake Idlong
CreatedUserIdCreator Id, not modifiablelong?
CreatedUserNameCreator, length 50, not modifiablestring
CreatedUserRealNameCreator name, length 50, not modifiablestring
CreatedTimeCreation time, not modifiableDateTime?
ModifiedUserIdModifier Idlong?
ModifiedUserNameModifier, length 50string
ModifiedUserRealNameModifier name, length 50string
ModifiedTimeModification timeDateTime?
IsDeletedWhether deleted, default falsebool

Version Entity

Inherit EntityVersion when row-level locking (optimistic locking) version number, soft delete, modification, and creation information is needed.
Each update automatically increments the version number by 1, and version number conditions are appended to queries

cs
/// <summary>
/// Module
/// </summary>
[Table(Name = "app_module")]
public class ModuleEntity : EntityVersion
{
}

Property description

PropertyDescriptionType
IdPrimary key Id, default snowflake Idlong
CreatedUserIdCreator Id, not modifiablelong?
CreatedUserNameCreator, length 50, not modifiablestring
CreatedUserRealNameCreator name, length 50, not modifiablestring
CreatedTimeCreation time, not modifiableDateTime?
ModifiedUserIdModifier Idlong?
ModifiedUserNameModifier, length 50string
ModifiedUserRealNameModifier name, length 50string
ModifiedTimeModification timeDateTime?
IsDeletedWhether deleted, default falsebool
VersionVersion, default 0long

Data Permission Entity

Inherit EntityData when data permissions are needed.
Inheriting the data permission entity adds OwnerId and OwnerOrgId fields, representing the data owner user Id and data owner department Id respectively.
OwnerId is used when data permission is set to personal, and OwnerOrgId is used when data permission is set to department.

cs
/// <summary>
/// Module
/// </summary>
[Table(Name = "app_module")]
public class ModuleEntity : EntityData
{
}

Property description

PropertyDescriptionType
IdPrimary key Id, default snowflake Idlong
OwnerIdOwner Idlong?
OwnerOrgIdOwner department Idlong?
CreatedUserIdCreator Id, not modifiablelong?
CreatedUserNameCreator, length 50, not modifiablestring
CreatedUserRealNameCreator name, length 50, not modifiablestring
CreatedTimeCreation time, not modifiableDateTime?
ModifiedUserIdModifier Idlong?
ModifiedUserNameModifier, length 50string
ModifiedUserRealNameModifier name, length 50string
ModifiedTimeModification timeDateTime?
IsDeletedWhether deleted, default falsebool

Tenant Entity

Inherit EntityTenant when isolating data for different tenants.
Inheriting the tenant entity adds a TenantId field representing the tenant Id.

cs
/// <summary>
/// Module
/// </summary>
[Table(Name = "app_module")]
public class ModuleEntity : EntityTenant
{
}

Property description

PropertyDescriptionType
IdPrimary key Id, default snowflake Idlong
TenantIdTenant Id, not modifiablelong?
CreatedUserIdCreator Id, not modifiablelong?
CreatedUserNameCreator, length 50, not modifiablestring
CreatedUserRealNameCreator name, length 50, not modifiablestring
CreatedTimeCreation time, not modifiableDateTime?
ModifiedUserIdModifier Idlong?
ModifiedUserNameModifier, length 50string
ModifiedUserRealNameModifier name, length 50string
ModifiedTimeModification timeDateTime?
IsDeletedWhether deleted, default falsebool

Tenant Data Permission Entity

Inherit EntityTenantWithData when both tenant and data permissions are needed

cs
/// <summary>
/// Module
/// </summary>
[Table(Name = "app_module")]
public class ModuleEntity : EntityTenantWithData
{
}

Property description

PropertyDescriptionType
IdPrimary key Id, default snowflake Idlong
TenantIdTenant Id, not modifiablelong?
OwnerIdOwner Idlong?
OwnerOrgIdOwner department Idlong?
CreatedUserIdCreator Id, not modifiablelong?
CreatedUserNameCreator, length 50, not modifiablestring
CreatedUserRealNameCreator name, length 50, not modifiablestring
CreatedTimeCreation time, not modifiableDateTime?
ModifiedUserIdModifier Idlong?
ModifiedUserNameModifier, length 50string
ModifiedUserRealNameModifier name, length 50string
ModifiedTimeModification timeDateTime?
IsDeletedWhether deleted, default falsebool

Member Entity

Inherit EntityMember when isolating data for different members.
Inheriting the member entity adds a MemberId field representing the member Id.

cs
/// <summary>
/// Module
/// </summary>
[Table(Name = "app_module")]
public class ModuleEntity : EntityMember
{
}

Property description

PropertyDescriptionType
IdPrimary key Id, default snowflake Idlong
MemberIdMember Id, not modifiablelong?
CreatedTimeCreation time, not modifiableDateTime?
ModifiedTimeModification time, not creatableDateTime?
IsDeletedWhether deleted, default falsebool

Member Tenant Entity

Inherit EntityMemberWithTenant when both member and tenant are needed

cs
/// <summary>
/// Module
/// </summary>
[Table(Name = "app_module")]
public class ModuleEntity : EntityMemberWithTenant
{
}

Property description

PropertyDescriptionType
IdPrimary key Id, default snowflake Idlong
TenantIdTenant Id, not modifiablelong?
MemberIdMember Id, not modifiablelong?
CreatedTimeCreation time, not modifiableDateTime?
ModifiedTimeModification time, not creatableDateTime?
IsDeletedWhether deleted, default falsebool

Inheriting Interfaces

Add Interface

Inherit IEntityAdd<TKey> when creation information is needed

cs
/// <summary>
/// Module
/// </summary>
[Table(Name = "app_module")]
public class ModuleEntity : IEntityAdd<long>
{
    /// <summary>
    /// Creator Id
    /// </summary>
    [Description("Creator Id")]
    [Column(Position = -22, CanUpdate = false)]
    public virtual long? CreatedUserId { get; set; }

    /// <summary>
    /// Creator
    /// </summary>
    [Description("Creator")]
    [Column(Position = -21, CanUpdate = false), MaxLength(50)]
    public virtual string CreatedUserName { get; set; }

    /// <summary>
    /// Creator name
    /// </summary>
    [Description("Creator name")]
    [Column(Position = -21, CanUpdate = false), MaxLength(50)]
    public virtual string CreatedUserRealName { get; set; }

    /// <summary>
    /// Creation time
    /// </summary>
    [Description("Creation time")]
    [Column(Position = -20, CanUpdate = false, ServerTime = DateTimeKind.Local)]
    public virtual DateTime? CreatedTime { get; set; }
}

Update Interface

Inherit IEntityUpdate<TKey> when modification information is needed

cs
/// <summary>
/// Module
/// </summary>
[Table(Name = "app_module")]
public class ModuleEntity : IEntityUpdate<long>
{
    /// <summary>
    /// Modifier Id
    /// </summary>
    [Description("Modifier Id")]
    [Column(Position = -12, CanInsert = false)]
    [JsonProperty(Order = 10000)]
    [JsonPropertyOrder(10000)]
    public virtual long? ModifiedUserId { get; set; }

    /// <summary>
    /// Modifier
    /// </summary>
    [Description("Modifier")]
    [Column(Position = -11, CanInsert = false), MaxLength(50)]
    [JsonProperty(Order = 10001)]
    [JsonPropertyOrder(10001)]
    public virtual string ModifiedUserName { get; set; }

    /// <summary>
    /// Modifier name
    /// </summary>
    [Description("Modifier name")]
    [Column(Position = -11), MaxLength(50)]
    [JsonProperty(Order = 10001)]
    [JsonPropertyOrder(10001)]
    public virtual string ModifiedUserRealName { get; set; }

    /// <summary>
    /// Modification time
    /// </summary>
    [Description("Modification time")]
    [JsonProperty(Order = 10002)]
    [JsonPropertyOrder(10002)]
    [Column(Position = -10, CanInsert = false, ServerTime = DateTimeKind.Local)]
    public virtual DateTime? ModifiedTime { get; set; }
}

Delete Interface

Inherit IDelete when soft delete is needed

cs
/// <summary>
/// Module
/// </summary>
[Table(Name = "app_module")]
public class ModuleEntity : IDelete
{
    /// <summary>
    /// Whether deleted
    /// </summary>
    [Description("Whether deleted")]
    [Column(Position = -9)]
    public virtual bool IsDeleted { get; set; } = false;
}

Version Interface

Inherit IVersion when row-level locking (optimistic locking) version number is needed.
Each time the entire entity is modified, the current version number is included for validation (version number increments on success, exception thrown on failure).

cs
/// <summary>
/// Module
/// </summary>
[Table(Name = "app_module")]
public class ModuleEntity : IVersion
{
    /// <summary>
    /// Version
    /// </summary>
    [Description("Version")]
    [Column(Position = -30, IsVersion = true)]
    public virtual long Version { get; set; }
}

Tenant Interface

Inherit ITenant when isolating data for different tenants.
Data is distinguished by tenant field.

cs
/// <summary>
/// Module
/// </summary>
[Table(Name = "app_module")]
public class ModuleEntity : ITenant
{
    /// <summary>
    /// Tenant Id
    /// </summary>
    [Description("Tenant Id")]
    [Column(Position = 2, CanUpdate = false)]
    [JsonProperty(Order = -20)]
    [JsonPropertyOrder(-20)]
    public virtual long? TenantId { get; set; }
}

Data Permission Interface

Inherit IData when data permissions are needed.
Data permissions can be set in role management: this department, this department and sub-departments, specified departments, own data.

cs
/// <summary>
/// Module
/// </summary>
[Table(Name = "app_module")]
public class ModuleEntity : IData
{
    /// <summary>
    /// Owner Id
    /// </summary>
    [Description("Owner Id")]
    [Column(Position = -41)]
    public virtual long? OwnerId { get; set; }

    /// <summary>
    /// Owner department Id
    /// </summary>
    [Description("Owner department Id")]
    [Column(Position = -40)]
    public virtual long? OwnerOrgId { get; set; }
}

Member Interface

Inherit IMember when isolating data for different members

cs
/// <summary>
/// Module
/// </summary>
[Table(Name = "app_module")]
public class ModuleEntity : IMember
{
    /// <summary>
    /// Member Id
    /// </summary>
    [Description("Member Id")]
    [Column(Position = -23, CanUpdate = false)]
    public virtual long? MemberId { get; set; }
}