Open Closed

Subscribe to entity event of specific interface that inherits it. #4418

User avatar
jeffbuot created
  • ABP Framework version: 6.0.2
  • DB provider: EF Core I have an interface with an entity:
public interface IReferenceObject{
    string ReferenceId {get;}

public class Book : FullAuditedAggregateRoot<Guid>, IReferenceObject{
    public Book(Guid id, string referenceId){
        Id = id;
        ReferenceId = referenceId;
    public string ReferenceId { get; }    
    public string Title { get; set; }

My goal is to subscribe on create event to every entities that inherits the IReferenceObject. I read the documentation here and tried this:

public class ReferenceObjectEventHandler : ILocalEventHandler<EntityCreatedEventData<IReferenceObject>>, ITransientDependency

    public async Task HandleEventAsync(EntityCreatedEventData<IReferenceObject> eventData)
        Console.WriteLine($"Created an entity with reference id {eventData.Entity.ReferenceId}");

But it's not working..any suggestion?

1 Answer(s)
  • User Avatar
    maliming created
    Support Team


    The EntityCreatedEventData only works for an entity.

Made with ❤️ on ABP v8.2.0 Updated on February 19, 2024, 12:29