Overriding Persistence Behaviour
By default, all fields in a LightSpeed entity are persistent: that is, LightSpeed expects to be able to load them from the database, and includes them when saving the entity.
Excluding a Field From Persistence
Some entities need to hold non-persistent state. For example, an entity might have a field which caches the result of an expensive calculation, or which represents some UI status which needs to be passed around with the entity but is not part of its persistent state. Such fields are known as transient fields.
To mark a field as transient in the designer, set its Transient option to true.
To mark a field as transient in code, apply TransientAttribute to the field.
Excluding a Field From Being Saved
Occasionally you will have a database column that you want to load, but not to save. The classic example is a computed column: it is useful to have the result of the computation, but trying to save a value back into that column would cause an error. In this case you do not want the field to be transient because transient fields are not loaded from the database – they are not persistent at all. You want the field should be loaded but not saved.
To exclude a field from being saved in the designer, set its Load Only option to true.
To exclude a field from being saved in code, make the field readonly (ReadOnly in Visual Basic).
Examples
Overriding persistence behaviour |
[Transient] |