Skip to content

Commit

Permalink
FK Filter casting issue fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ackava committed Nov 3, 2022
1 parent 3f4a699 commit 4a36b6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion NeuroSpeech.EntityAccessControl/DbEntityEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public virtual Task UpdatedAsync(T entity)
{
return null;
}
return ForeignKeyFilter(new ForeignKeyInfo<T>((entity as EntityEntry<T>)!, key, value, fs));
return ForeignKeyFilter(new ForeignKeyInfo<T>(entity, key, value, fs));
}

protected virtual IQueryContext? ForeignKeyFilter(ForeignKeyInfo<T> fk)
Expand Down
11 changes: 6 additions & 5 deletions NeuroSpeech.EntityAccessControl/Security/FilterFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,29 @@ namespace NeuroSpeech.EntityAccessControl.Security
public readonly ref struct ForeignKeyInfo<T>
where T : class
{
public readonly EntityEntry<T> 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<T> 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<TR>(Expression<Func<T,TR>> exp)
Expand Down

0 comments on commit 4a36b6d

Please sign in to comment.