Schemas

Reviewing the Database Schema

Each table derives it's schema from public instance fields contained within the object. For example, take the following class definition:
    /// <summary>
    /// Represents a descrete time-based sample of volatage from the device's Analog-to-Digital converter.
    /// </summary>
    [Serializable]
    public class AnalogSample
    {
        /// <summary>
        /// The time the sample was sampled.
        /// </summary>
        public DateTime Sampled;

        /// <summary>
        /// The sample itself.
        /// </summary>
        public int Voltage;

        /// <summary>
        /// Initializes a new instance of the AnalogSample class.
        /// </summary>
        /// <param name="time">Timestamp of the sample when it was taken.</param>
        /// <param name="sample">The value of the sample.</param>
        public AnalogSample(DateTime time, int sample)
        {
            this.Sampled = time;
            this.Voltage = sample;
        }
    }

Using the static method Database.DumpSchema, you can review the interpreted structure of all tables in the database. Using the above example, the result issued in the debugger output would be:
TABLE AnalogSample {
	Sampled (System.DateTime) 
	Voltage (System.Int32) 
}

Rules for Objects

  • In order to be serialized, your object must be tagged with the Serializable attribute (System.SerializableAttribute), and the desired fields must also be serializable.
  • Fields must be marked with the public accessor, and must be an instance field.

Last edited Mar 5, 2011 at 1:17 PM by Solidus117, version 2

Comments

No comments yet.