diff --git a/NeuroSpeech.EntityAccessControl/DbEntityEvents.cs b/NeuroSpeech.EntityAccessControl/DbEntityEvents.cs index 8ce05cd..b43a18b 100644 --- a/NeuroSpeech.EntityAccessControl/DbEntityEvents.cs +++ b/NeuroSpeech.EntityAccessControl/DbEntityEvents.cs @@ -234,7 +234,7 @@ public virtual Task UpdatedAsync(T entity) { return null; } - return ForeignKeyFilter(new ForeignKeyInfo((entity as EntityEntry)!, key, value, fs)); + return ForeignKeyFilter(new ForeignKeyInfo(entity, key, value, fs)); } protected virtual IQueryContext? ForeignKeyFilter(ForeignKeyInfo fk) diff --git a/NeuroSpeech.EntityAccessControl/Security/FilterFactory.cs b/NeuroSpeech.EntityAccessControl/Security/FilterFactory.cs index 2781360..6dde8a7 100644 --- a/NeuroSpeech.EntityAccessControl/Security/FilterFactory.cs +++ b/NeuroSpeech.EntityAccessControl/Security/FilterFactory.cs @@ -10,28 +10,29 @@ namespace NeuroSpeech.EntityAccessControl.Security public readonly ref struct ForeignKeyInfo where T : class { - public readonly EntityEntry Entry; + public readonly EntityEntry Entry; + public readonly T Entity; public readonly PropertyInfo Property; public readonly object Value; private readonly FilterFactory factory; - public readonly string Name; + public string Name => Property.Name; public ForeignKeyInfo( - EntityEntry entry, + EntityEntry entry, PropertyInfo property, object value, FilterFactory factory) { this.Entry = entry; + this.Entity = (T)entry.Entity; this.Property = property; this.Value = value; this.factory = factory; - this.Name = property.Name; } public bool Is(string name) { - return this.Name == name; + return this.Property.Name == name; } public bool Is(Expression> exp)