Maps a property of a child object to its parent object.

Namespace: Castle.ActiveRecord
Assembly:  Castle.ActiveRecord (in Castle.ActiveRecord.dll)
Version: 1.0.3.0

Syntax

C#
[SerializableAttribute]
[AttributeUsageAttribute(AttributeTargets.Property, AllowMultiple = false)]
public class NestedParentReferenceAttribute : Attribute

Examples

The following code illustrates the use of a parent Company class
CopyC#
public class PostalAddress
{
    private Company _company;
    private String _address;
    private String _city;
    private String _state;
    private String _zipcode;

    [Parent]
    public Company Parent
    {
        get { return _company; }
        set { _company = value; }
    }

    [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; }
    }
}

[ActiveRecord("Companies")]
public class Company : ActiveRecordBase
{
    private int id;
    private PostalAddress _address;

    public Company()
    {
    }

    public Company(string name)
    {
        this.name = name;
    }

    [PrimaryKey]
    public int Id
    {
        get { return id; }
        set { id = value; }
    }

    [Nested]
    public PostalAddress Address
    {
        get { return _address; }
        set { _address = value; }
    }
}

Inheritance Hierarchy

System..::Object
  System..::Attribute
    Castle.ActiveRecord..::NestedParentReferenceAttribute

See Also