Support forum for ASP.NET Zero (https://aspnetzero.com/).
By ManojReddy
#27039 I'm using Project Version: 5.1.0 and .Net Core 2.0 framework. I'm trying to implement an Audit/History table for my Entity so that I can see the deleted and old column values for a table.

Entity Class:

Code: Select all[Table("TestingEntity")]
[Audited]
public class TestingEntity : AuditedEntity , IMayHaveTenant
{
    public int? TenantId { get; set; }

    public virtual string Code { get; set; }
}


ApplicationModule Class:

Code: Select allpublic class MyCompanyApplicationModule : AbpModule
{
    public override void PreInitialize()
    {
        //Adding authorization providers
        Configuration.Authorization.Providers.Add<AppAuthorizationProvider>();

        //Adding custom AutoMapper configuration
        Configuration.Modules.AbpAutoMapper().Configurators.Add(CustomDtoMapper.CreateMappings);

        Configuration.EntityHistory.IsEnabledForAnonymousUsers = true;

        Configuration.EntityHistory.Selectors.Add(new NamedTypeSelector("Abp.AuditedEntities", type => typeof(IAudited).IsAssignableFrom(type)));
    }

    public override void Initialize()
    {
        IocManager.RegisterAssemblyByConvention(typeof(MyCompanyApplicationModule).GetAssembly());
    }
}


Running following queries giving no results.

Code: Select allSELECT * FROM [AbpEntityChangeSets]
SELECT * FROM [AbpEntityPropertyChanges]
SELECT * from [AbpEntityChanges]


Referece: https://aspnetboilerplate.com/Pages/Documents/Entity-History
By alirizaadiyahsi
#27047 You pass parameter type => typeof(IAudited) but I can not see any entities that is type of IAudited entity.
Could you change it with AuditedEntity ? I mean something like following:

Code: Select allConfiguration.EntityHistory.Selectors.Add(new NamedTypeSelector("Abp.AuditedEntities", type => typeof(AuditedEntity).IsAssignableFrom(type)));
By ManojReddy
#27061 It is not giving proper results when I'm deleting an entity item.

Its inserting records for each property with old and new value same in [AbpEntityPropertyChanges] table.

And there is no clear information that this entity item is deleted and its deletion time, DeletedBy.

Is this due to using AuditeEntity in my Entity class? I'm using hard delete so I thought not to add these columns is deleted and its deletion time, DeletedBy to table.

EntityChangeId 3 is for deletion.
Attachments
Capture.PNG
AbpEntityPropertyChanges table
Capture.PNG (14.9 KiB) Viewed 251 times