Thursday, March 11, 2010

SaveContents property on the table fields

I've opened for myself the new great property of the table fields - SaveContents. This property defines whether field will be physically created in the database (Yes) or will it just be present on the table buffer (No). It can be quite useful to have such kind of fields if you want to avoid redundancies in the database but you need to perform some complex calculations/queries and use their results on the table buffer. To get these fields filled with values you have to override the postLoad() method on the table.
For example, let you have the table:

Table1
IntField1 : Int, SaveContents = Yes
IntField2 : Int, SaveContents = Yes
IntField3 : Int, SaveContents = No

If you'll override postLoad() method on the Table1 like:

public void postLoad()
{
    this.IntField3 = this.IntField1 + this.IntField2;
}

then you'll get the IntField3 field filled with the sum of the other two field values. The postLoad() method will be executed on each query on Table1 table. That is huge drawback because of serious performance degradation, however it still can be useful sometimes.

2 comments:

  1. Genuinely when someone doesn't understand after that its up to other users that
    they will help, so here it takes place.

    Review my page; party rentals nyc Bronx

    ReplyDelete