Working with window mode (unsliced) objects

If you have reference to any revisioned subobject of PolicyPeriod, simply get its Unsliced property to get a reference to that entity instance in unsliced mode. Remember to save the return result. The original reference is unchanged.

Note: The PolicyPeriod entity instance is not a revisioned entity instance. It is the root of the graph of revisioned objects and it does not have an Unsliced property.

Version lists always return entities in window mode (‘unsliced’ mode)

If you get a version of an entity instance from a version list, Gosu always returns that entity instance as a window mode entity instance. In other words, you have the entity reference but no implicit slice date. This means that the entity instance represents the car over a range of dates.

With an unsliced entity instance, you can access simple properties on the object but you cannot access links to other entities (foreign keys and arrays of entity instances).

Window mode entities from database queries

The typical way to get window mode versions of entities is to use version lists. However, there are other ways to get a window-mode reference to an entity instance if you have a slice mode reference to an entity instance.

The most common other way to reference an entity instance in window mode is an entity instance that you retrieve through a database query. See Query builder APIs for related information.

Database query results do not have any inherent context from which to determine a slice date. Thus, by default any objects from a database query return in window mode (and in a read-only bundle). It is usually correct to then convert the item into slice mode as of a certain date with the version list getSlice method:

var sliceModeVehicle = myVehicle.getSlice(sliceDate)

However, it depends on the context. In some cases, you might want to work with the object in window mode.

Naming conventions

When reading code, you may get confused as to whether you are working with sliced or unsliced objects. One approach to improving code readability (and reducing coding errors) is to consistently name variables. For variables that contain unsliced objects, include the suffix Unsliced. For example, policyLineUnsliced.

The convention is that variables that do not have the Unsliced suffix contain a sliced version (the more common case).

For example:

var firstVersionUnsliced = vehicleVL.AllVersions.First()
var drivers = firstVersion.getSlice(firstVersion.EffectiveDate).Drivers