Mindscape
  • Register
  • Login
  • YOUR CART IS EMPTY
home
Software
  • Developers Toolbox
  • LightSpeed
  • Raygun
  • WPF Elements
  • Web Workbench
  • Metro Elements
  • Silverlight Elements
  • NHibernate Designer
  • Phone Elements
  • WPF Diagrams
  • Simple DB management
  • Visual Tools for SharePoint
Downloads
Store
  • Buy online
  • Purchase order
  • Volume discounts
  • Reseller
  • Software license
  • Contact sales
Blog
Support
About
  • About Us
  • Contact
  • Testimonials
rss
twitter
facebook
Controlling the Database Mapping Understanding the Default Mapping Overriding the Default Mapping Overriding Persistence Behaviour Identity Generation Working with Database Views Invoking Stored Procedures

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]
private EditStatus _editStatus; // neither loaded nor saved
private readonly decimal _discountedPrice; // loaded, but not saved

Data Products

  • LightSpeed ORM
  • NHibernate Designer
  • SimpleDB Tools
  • SharePoint Tools

DevOp Tools

  • Raygun

Visual Controls

  • WPF Elements
  • WPF Diagrams
  • Silverlight Elements
  • Phone Elements

Popular Products

  • Web Workbench

    Modern web development for Visual Studio!

  • Mindscape Megapack

    All Mindscape products for one awesome price!

Quick Links

  • Forums
  • Blog
  • Register
  • Login
  • Contact us
  • Twitter
  • Facebook
  • Google+
  • YouTube
  • Linkedin
  • Rss

© Mindscape 2025. Mindscape is a registered trademark of Mindscape Limited.

  • Terms
  • Privacy