Angular & ASP.Net Core
ABP version 8.1
ABP framework 5.1.0
When I activate Entity History, It detects when I create and detele an entity. When I update an entity, It doesn't detected.
I follow all the instructions here : https://aspnetboilerplate.com/Pages/Documents/Entity-History && https://docs.aspnetzero.com/en/aspnet-core-angular/latest/Features-Angular-Entity-History
Tryed both configurations :
OR
Is there something missing ?
12 Answer(s)
-
0
-
0
-
0
Hi @elferone,
Could you share the entity you have this problem with ?
Thanks,
-
0
-
0
Hi elferone, I tested it based on the entity you provided, and it also works. Test ApplicationService:
public class TestAppService : QADemoDemoAppServiceBase { private readonly IRepository<Role> _roleRepository; private readonly IRepository<MemberActivityEntity> _memberActivityEntityRepository; public TestAppService(IRepository<Role> roleRepository, IRepository<MemberActivityEntity> memberActivityEntityRepository) { _roleRepository = roleRepository; _memberActivityEntityRepository = memberActivityEntityRepository; } [UnitOfWork] public async Task<string> TestMethod() { var roleList = await _roleRepository.GetAllListAsync(); var role = roleList.First(); // default admin role role.DisplayName = "ADMIN-2"; await _roleRepository.UpdateAsync(role); var activityEntities = await _memberActivityEntityRepository.GetAllListAsync(); var act = activityEntities.First(); // custom entity act.Description = "New Desc"; await _memberActivityEntityRepository.UpdateAsync(act); await CurrentUnitOfWork.SaveChangesAsync(); return "Success"; } }
Custom Entity:
public class MemberActivityEntity : FullAuditedEntity<int> { [Column("MemberActivityId")] public override int Id { get; set; } [Required] [StringLength(64)] public string Code { get; set; } [Required] [StringLength(1024)] public string Description { get; set; } [Required] public bool UseSpouseInfo { get; set; } [Required] public bool IsActiveForInsurance { get; set; } [Required] public bool IsActive { get; set; } [Required] public bool IsRetired { get; set; } public byte? PeriodCount { get; set; } [Required] public bool IsArchived { get; set; } }
Module configuration:
Configuration.EntityHistory.IsEnabled = true; Configuration.EntityHistory.Selectors.Add(new NamedTypeSelector( "Abp.FullAuditedEntities", type => typeof(IFullAudited).IsAssignableFrom(type) ));
-
0
Is is necessary to use : await CurrentUnitOfWork.SaveChangesAsync(); ?
-
0
I went and got an empty project. I tested on it and the update was working. When I activate lazy loading it stopped working.
So the source of the problem was the lazy loading. Now I have to find a way to make it work together.
Does anybody faced the same problem ?
-
0
Hi @elferone
Thank you for sharing the solution. Could you share how did you enable lazy loading ?
-
0
-
0
Hi @elferone,
Could you create an issue on https://github.com/aspnetboilerplate/aspnetboilerplate ? We will take a deep look at into this for the next version of ABP.
-
0
Hi,
This is the link of the issue created :
https://github.com/aspnetboilerplate/aspnetboilerplate/issues/5996
-
0
Thanks @elferone
I have added this issue to 6.3 milestone. We will work on it soon.