Class AllowExpandAttribute
Names the navigation properties a client may expand from this entity type. Anything not named is refused.
[AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
public class AllowExpandAttribute : Attribute
- Inheritance
-
AllowExpandAttribute
- Inherited Members
Remarks
A path is judged one hop at a time, by the type each hop starts from, so
Orders.OrderDetails needs Orders allowed on Customer and
OrderDetails allowed on Order. Each type therefore declares only its own
outbound navigations; nobody writes whole paths.
An allow-list means "these and no others". Use DenyExpandAttribute instead where a type has many navigations and only a few are sensitive.
[AllowExpand(nameof(Orders))]
public class Customer {
public ICollection<Order> Orders { get; set; }
public ICollection<Note> Notes { get; set; } // refused
}
ExpandPolicy has the equivalent for a model whose classes are generated and cannot carry attributes, and decides what happens when both are present.
Constructors
AllowExpandAttribute(params string[])
Name the navigations a client may expand from this type.
public AllowExpandAttribute(params string[] navigations)
Parameters
navigationsstring[]The navigation property names, as declared on this type.
Properties
Navigations
The navigation property names this type permits.
public string[] Navigations { get; }
Property Value
- string[]