Implementing Policies in HandCoded Entities
As indicated above, LightSpeed’s storage policies are implemented using specially named fields. In fact, storage policies are determined by the presence of these specially named fields. In hand‑coded entities, therefore, you can implement a storage policy just by declaring a field with the appropriate name.
Implementing time tracking in a hand-coded entity |
public class Document : Entity<int> |
Special fields should normally be marked readonly as they should be modified only by LightSpeed, not by application code. This will cause a compiler warning because there is no way to set the fields: you should disable this warning as shown above. ASP.NET medium trust environments do not allow LightSpeed to modify readonly fields: if you plan to use your model in such an environment, implement the special fields as read‑write.
Column Names for Policy Fields
The LightSpeed fields for storage policies must have the names listed above. If you need to use different column names in the database, you can map them using ColumnAttribute or LightSpeedContext.NamingStrategy. This option is only available when hand-coding entities.