
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
| Property | Description | Type |
|---|---|---|
| Id | Primary key Id, default snowflake Id | long |
Create Entity
Inherit EntityAdd when creation information is needed
cs
/// <summary>
/// Module
/// </summary>
[Table(Name = "app_module")]
public class ModuleEntity : EntityAdd
{
}Property description
| Property | Description | Type |
|---|---|---|
| Id | Primary key Id, default snowflake Id | long |
| CreatedUserId | Creator Id, not modifiable | long? |
| CreatedUserName | Creator, length 50, not modifiable | string |
| CreatedUserRealName | Creator name, length 50, not modifiable | string |
| CreatedTime | Creation time, not modifiable | DateTime? |
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
| Property | Description | Type |
|---|---|---|
| Id | Primary key Id, default snowflake Id | long |
| CreatedUserId | Creator Id, not modifiable | long? |
| CreatedUserName | Creator, length 50, not modifiable | string |
| CreatedUserRealName | Creator name, length 50, not modifiable | string |
| CreatedTime | Creation time, not modifiable | DateTime? |
| ModifiedUserId | Modifier Id | long? |
| ModifiedUserName | Modifier, length 50 | string |
| ModifiedUserRealName | Modifier name, length 50 | string |
| ModifiedTime | Modification time | DateTime? |
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
| Property | Description | Type |
|---|---|---|
| Id | Primary key Id, default snowflake Id | long |
| CreatedUserId | Creator Id, not modifiable | long? |
| CreatedUserName | Creator, length 50, not modifiable | string |
| CreatedUserRealName | Creator name, length 50, not modifiable | string |
| CreatedTime | Creation time, not modifiable | DateTime? |
| ModifiedUserId | Modifier Id | long? |
| ModifiedUserName | Modifier, length 50 | string |
| ModifiedUserRealName | Modifier name, length 50 | string |
| ModifiedTime | Modification time | DateTime? |
| IsDeleted | Whether deleted, default false | bool |
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
| Property | Description | Type |
|---|---|---|
| Id | Primary key Id, default snowflake Id | long |
| CreatedUserId | Creator Id, not modifiable | long? |
| CreatedUserName | Creator, length 50, not modifiable | string |
| CreatedUserRealName | Creator name, length 50, not modifiable | string |
| CreatedTime | Creation time, not modifiable | DateTime? |
| ModifiedUserId | Modifier Id | long? |
| ModifiedUserName | Modifier, length 50 | string |
| ModifiedUserRealName | Modifier name, length 50 | string |
| ModifiedTime | Modification time | DateTime? |
| IsDeleted | Whether deleted, default false | bool |
| Version | Version, default 0 | long |
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
| Property | Description | Type |
|---|---|---|
| Id | Primary key Id, default snowflake Id | long |
| OwnerId | Owner Id | long? |
| OwnerOrgId | Owner department Id | long? |
| CreatedUserId | Creator Id, not modifiable | long? |
| CreatedUserName | Creator, length 50, not modifiable | string |
| CreatedUserRealName | Creator name, length 50, not modifiable | string |
| CreatedTime | Creation time, not modifiable | DateTime? |
| ModifiedUserId | Modifier Id | long? |
| ModifiedUserName | Modifier, length 50 | string |
| ModifiedUserRealName | Modifier name, length 50 | string |
| ModifiedTime | Modification time | DateTime? |
| IsDeleted | Whether deleted, default false | bool |
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
| Property | Description | Type |
|---|---|---|
| Id | Primary key Id, default snowflake Id | long |
| TenantId | Tenant Id, not modifiable | long? |
| CreatedUserId | Creator Id, not modifiable | long? |
| CreatedUserName | Creator, length 50, not modifiable | string |
| CreatedUserRealName | Creator name, length 50, not modifiable | string |
| CreatedTime | Creation time, not modifiable | DateTime? |
| ModifiedUserId | Modifier Id | long? |
| ModifiedUserName | Modifier, length 50 | string |
| ModifiedUserRealName | Modifier name, length 50 | string |
| ModifiedTime | Modification time | DateTime? |
| IsDeleted | Whether deleted, default false | bool |
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
| Property | Description | Type |
|---|---|---|
| Id | Primary key Id, default snowflake Id | long |
| TenantId | Tenant Id, not modifiable | long? |
| OwnerId | Owner Id | long? |
| OwnerOrgId | Owner department Id | long? |
| CreatedUserId | Creator Id, not modifiable | long? |
| CreatedUserName | Creator, length 50, not modifiable | string |
| CreatedUserRealName | Creator name, length 50, not modifiable | string |
| CreatedTime | Creation time, not modifiable | DateTime? |
| ModifiedUserId | Modifier Id | long? |
| ModifiedUserName | Modifier, length 50 | string |
| ModifiedUserRealName | Modifier name, length 50 | string |
| ModifiedTime | Modification time | DateTime? |
| IsDeleted | Whether deleted, default false | bool |
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
| Property | Description | Type |
|---|---|---|
| Id | Primary key Id, default snowflake Id | long |
| MemberId | Member Id, not modifiable | long? |
| CreatedTime | Creation time, not modifiable | DateTime? |
| ModifiedTime | Modification time, not creatable | DateTime? |
| IsDeleted | Whether deleted, default false | bool |
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
| Property | Description | Type |
|---|---|---|
| Id | Primary key Id, default snowflake Id | long |
| TenantId | Tenant Id, not modifiable | long? |
| MemberId | Member Id, not modifiable | long? |
| CreatedTime | Creation time, not modifiable | DateTime? |
| ModifiedTime | Modification time, not creatable | DateTime? |
| IsDeleted | Whether deleted, default false | bool |
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; }
}