expressappframework-113471-business-model-design-orm-non-persistent-objects-how-to-display-a-non-persistent-objects-detail-view-from-the-navigation.md
Declare a non-persistent class, apply the DomainComponentAttribute to it, and add an object key property.
Rebuild the solution.
Run the Model Editor for a module project and add a new navigation item. Set the IModelNavigationItem.View property to the identifier of the Detail View to be displayed (for example, NonPersistentObject_DetailView ). Set the IModelNavigationItem.ObjectKey property to an arbitrary integer value. Note that this value should be unique if you want to display different non-persistent objects of this type.
Open the application’s Startup.cs and ensure that the Non-Persistent Object Space Provider is registered in the Application Builder code. The Template Kit adds this code automatically.
In the Application Builder code, subscribe to the OnObjectSpaceCreated event. In the event handler, subscribe to the NonPersistentObjectSpace.ObjectByKeyGetting event. In the ObjectByKeyGetting event handler, check if the requested object type is NonPersistentObject. If so, pass a NonPersistentObject instance with the key value specified in step 3 as the e.Object event parameter.
To show non-persistent objects in a DashboardView, follow the steps from the previous section and create a dashboard item instead of the navigation item. Refer to the DashboardView class description for information on how a Detail View binds to a Dashboard View item.
Refer to the following topics for more information and examples:
To execute simple business logic and prompt a user for parameters, use the ActionAttribute as shown in the How to: Create an Action Using the Action Attribute topic.
See Also
How to: Display a Non-Persistent Object's List View from the Navigation