Class EagerLoadAttribute
- Namespace
- JsonApiDotNetCore.Resources.Annotations
- Assembly
- JsonApiDotNetCore.Annotations.dll
Used to unconditionally load a related entity that is not exposed as a JSON:API relationship.
[PublicAPI]
[AttributeUsage(AttributeTargets.Property)]
public sealed class EagerLoadAttribute : Attribute
- Inheritance
-
EagerLoadAttribute
- Inherited Members
Remarks
This is intended for calculated properties that are exposed as JSON:API attributes, which depend on a related entity to always be loaded.
public class User : Identifiable<long>
{
[Attr(AttrCapabilities.AllowFilter | AttrCapabilities.AllowSort)]
[NotMapped]
public string DisplayName => Name.First + " " + Name.Last;
[EagerLoad]
public Name Name { get; set; }
}
public class Name // not exposed as resource, only database table
{
public string First { get; set; }
public string Last { get; set; }
}
public class Blog : Identifiable<long>
{
[HasOne]
public User Author { get; set; }
}
Properties
Children
public IReadOnlyCollection<EagerLoadAttribute> Children { get; }
Property Value
Property
public PropertyInfo Property { get; }