无法在ASP.NET零中启用实体历史记录 [英] Can't enable Entity History in ASP.NET Zero
问题描述
我正在使用ASP.NET Zero.项目版本: 5.1.0 和.NET Core 2.0模板.我正在尝试为我的实体启用实体历史记录",以便可以看到表的已删除列和旧列值.
I'm using ASP.NET Zero. Project Version: 5.1.0 and .NET Core 2.0 template. I'm trying to enable Entity History for my entity so that I can see the deleted and old column values for the table.
实体类:
[Table("TestingEntity")]
[Audited]
public class TestingEntity : AuditedEntity , IMayHaveTenant
{
public int? TenantId { get; set; }
public virtual string Code { get; set; }
}
ApplicationModule类:
public class MyCompanyApplicationModule : AbpModule
{
public override void PreInitialize()
{
// ...
Configuration.EntityHistory.IsEnabledForAnonymousUsers = true;
Configuration.EntityHistory.Selectors.Add(new NamedTypeSelector("Abp.AuditedEntities", type => typeof(IAudited).IsAssignableFrom(type)));
}
// ...
}
运行以下查询不会产生任何结果.
Running the following queries give no results.
SELECT * FROM [AbpEntityChangeSets]
SELECT * FROM [AbpEntityPropertyChanges]
SELECT * from [AbpEntityChanges]
参考: https://aspnetboilerplate.com/Pages/文档/实体历史记录
当我删除一个实体项目时,它没有给出正确的结果.
It is not giving proper results when I'm deleting an entity item.
它正在为每个属性插入记录,这些记录的旧值和新值与 [AbpEntityPropertyChanges]
表中的值相同.
It's inserting records for each property with old and new values the same in [AbpEntityPropertyChanges]
table.
并且没有明确的信息表明该实体项已被删除,其删除时间和DeletedBy.
And there is no clear information that this entity item is deleted, its deletion time, and DeletedBy.
这是由于在我的实体类中使用 AuditedEntity
吗?我正在使用硬删除,因此我想不要将这些列添加到表中:被删除,删除时间和DeletedBy.
Is this due to using AuditedEntity
in my entity class? I'm using hard delete, so I thought not to add these columns to the table: is deleted, its deletion time, and DeletedBy.
推荐答案
在ASP.NET零中禁用了实体历史记录.您可以启用它:
Entity History is disabled in ASP.NET Zero. You can enable it:
Configuration.EntityHistory.IsEnabled = true;
更新
当我删除一个实体项目时,它没有给出正确的结果.
It is not giving proper results when I'm deleting an entity item.
它正在为每个属性插入记录,这些记录的旧值和新值与 [AbpEntityPropertyChanges]
表中的值相同.
It's inserting records for each property with old and new values the same in [AbpEntityPropertyChanges]
table.
已在PR #2977 中解决,该问题将与ABP一起发布v3.5.
That has been resolved in PR #2977, which will be released with ABP v3.5.
并且没有明确的信息表明该实体项已被删除,其删除时间和DeletedBy.
And there is no clear information that this entity item is deleted, its deletion time, and DeletedBy.
这是由于在我的实体类中使用 AuditedEntity
吗?我正在使用硬删除,因此我想不要将这些列添加到表中:被删除,删除时间和DeletedBy.
Is this due to using AuditedEntity
in my entity class? I'm using hard delete, so I thought not to add these columns to the table: is deleted, its deletion time, and DeletedBy.
您不会在 AbpEntityPropertyChanges
表中找到这些,因为这些不是属性更改.
You won't find those in AbpEntityPropertyChanges
table, since those aren't property changes.
- 已删除该实体的信息:
EntityChange.ChangeType
- 其删除时间: <代码>EntityChangeSet.CreationTime
- DeletedBy:
EntityChangeSet.UserId
我们是否有计划为此功能添加UI?这样我们就可以从UI中查看实体历史记录.
Do we have a plan to add UI for this feature? So that we can see Entity History from UI.
此内容已添加到ASP.NET零 5.4.0 中.
This has been added in ASP.NET Zero 5.4.0.
这篇关于无法在ASP.NET零中启用实体历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!