Monthly Archives: February 2014

Navigation Properties in ASNA Visual RPG (AVR)

ASNA Visual RPG (AVR) is a .NET program language developed by ASNA. In this post I will cover the topic of navigation properties in an AVR class. In order to demonstrate navigation properties, I created a business domain object model consisting of two plain old runtime class objects POCO Classes. The first class represents an order header and the second class represents an order line item.

Here are come code snippets from both classes;

The Order Class

The Item Class

Please notice the Items (plural) property of the Order class. The Items property is a type of generic list consisting of Item objects. This forms a one-to-many relationship between an order and line items in the order. In this structure the Items property is also a navigation property. A navigation property is an optional property on an entity type that allows for navigation from one end of an association to the other end.

Notice also that the Item class has a navigation property of Order (singular). An Item can exist in only one order. The remote end point of an item is a single order, a multiplicity of one. The remote end point of an order is one-to-many items, a multiplicity of many.

Remember, the definition of a navigation property states that it is optional. For example, when an Order object is populated with data, it is usually desirable to also populate the Items property of the order, with a list of all the line Items associated with that order. On the other hand, when an Item is populated with data, it is not always desirable to populate the Order property of the Item, especially when the Item is part of a collection of Items in that Order. The multiplicity between Orders and Items would be repeated over and over again in the collection of order items. This would be very inefficient. However, when creating a single instance of an Item object, that is not part of a collection of items, it is desirable to populate the order property of the Item object. ASNA Visual RPG for .NET provides the flexibility needed to resolve a scenario like this, with an optional navigation property.

Here is an AVR function I called “PopulateItemEntity” that populates all of the properties of the Item class except the Order property. By not assigning a value to the Item.Order property, the setter method of the Order property is not invoked, leaving the property with a null value.

In case you are wondering why the Order property of the Item class has a modifier of *Overridable, don’t worry, I will cover that in my next post.