Home

Castle Stronghold

NestedAttribute API Document

Maps properties of a child object to columns of the table of a parent class.

Example

The following code illustrates the use of a nested PostalAddress

class


    [ActiveRecord("Companies")]
    public class Company : ActiveRecordBase
    {
        private int id;
        private PostalAddress _address;
    
        public Company()
        {
        }
    
        public Company(string name)
        {
            this.name = name;
        }
    
        [PrimaryKey]
        private int Id
        {
            get { return id; }
            set { id = value; }
        }
    
        [Nested]
        public PostalAddress Address
        {
            get { return _address; }
            set { _address = value; }
        }
    }
    
    public class PostalAddress
    {
        private String _address;
        private String _city;
        private String _state;
        private String _zipcode;
    
        [Property]
        public String Address
        {
            get { return _address; }
            set { _address = value; }
        }
    
        [Property]
        public String City
        {
            get { return _city; }
            set { _city = value;}
        }
    
        [Property]
        public String State
        {
            get { return _state; }
            set { _state = value; }
        }
    
        [Property]
        public String ZipCode
        {
            get { return _zipcode; }
            set { _zipcode = value; }
        }
    }

Constructors

NestedAttribute()

Informs ActiveRecord that the marked property contains nested elements, contained in a separate, reusable class.

NestedAttribute(String columnPrefix)

Informs ActiveRecord that the marked property contains nested elements, contained in a separate, reusable class.

ParameterDescription
columnPrefix A prefix to insert before each column in the nested component

Properties

NameTypeDescription
MapTypeType Allows one to reference a different type than the property type
UpdateBoolean Set to false to ignore this nested component when updating entities of this ActiveRecord class.
InsertBoolean Set to false to ignore this nested component when inserting entities of this ActiveRecord class.
ColumnPrefixString A prefix to insert before each column in the nested component.

Google
Search WWW Search castleproject.org