If you are using relations in you database you sometimes want to resolve them on server side and get the complete object to the client.
You can control that by using the
include operation (It works like the include operation of EF Core). It will perform a join operation on database side.
This example consists of two models: A user object with entries and the entries with a reference to the user.
Display users with entries
This basic example shows how to query data with its navigation properties included
Create/Update user entries
You can also update/create entries that are loaded by including them in the normal update operations.
If you want to disable the possibility to edit the values using this way remove the
[Updatable]-attribute from the navigation property and add the attribute
Display entries with user
- The related objects are loaded without checking for authorization. All related values and fields will get loaded.
- It is possible to create/update new objects when putting them in the navigation property
- You can control the behavior of updating/creating navigation properties by using the attributes
- It is recommended to mark all navigation properties with
[NonCreatable]. This will force you to create/update objects using the methods on the specific collections.
- When anything in the database changes that is related to the loaded data, the complete query gets executed again. That can have a negative impact on performance.