You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am updating from HC12 to HC13 and in my code I am trying to pull back via reflection the authorize and policy attributes we have applied to our EFCore Data model. The code is below:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am updating from HC12 to HC13 and in my code I am trying to pull back via reflection the authorize and policy attributes we have applied to our EFCore Data model. The code is below:
private Dictionary<string, List> InitializeObjectFieldInfo(ISchema schema)
{
var entityTypes = E920DbContextwrapper.GetContext().Model.GetEntityTypes();
return schema.Types
.Where(t => entityTypes
.Select(e => e.ClrType)
.Contains(t.ToRuntimeType())
&& t.GetType().IsAssignableTo(typeof(ObjectType)))
.Select(t => (ObjectType)t)
.SelectMany(o => o.Fields)
.Where(f => f.Directives
.Any(d => d.Type.RuntimeType == typeof(AuthorizeDirective)))
.GroupBy(f => f.DeclaringType.RuntimeType)
.ToDictionary(grouping => grouping.Key.Name.ToLower(),
grouping => grouping.Select(field => new ObjectFieldInfo
{
RuntimeTypeName = grouping.Key.Name,
FieldName = field.Name,
Policy = field.Directives
.FirstOrDefault(f => f.Type.RuntimeType == typeof(AuthorizeDirective))
?.ToObject()?.Policy
})
.Where(fi =>
{
var keys = entityTypes.FirstOrDefault(e => e.ClrType.Name.ToLower() == fi.RuntimeTypeName.ToLower())?.FindPrimaryKey();
return keys == null || !keys.Properties.Any(p => p.Name.ToLower() == fi.FieldName.ToLower());
})
.ToList(), StringComparer.InvariantCultureIgnoreCase);
}
ToObject errors out. The error is "Directive does not contain a definition for ToObject accepting a first argument of type Directive could be found"
Has the something in the code changed?
Beta Was this translation helpful? Give feedback.
All reactions