Table of contents
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 PostalAddressclass
[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.
| Parameter | Description |
|---|---|
| columnPrefix | A prefix to insert before each column in the nested component |
Properties
| Name | Type | Description |
|---|---|---|
| MapType | Type | Allows one to reference a different type than the property type |
| Update | Boolean | Set to false to ignore this nested component when updating entities of this ActiveRecord class. |
| Insert | Boolean | Set to false to ignore this nested component when inserting entities of this ActiveRecord class. |
| ColumnPrefix | String | A prefix to insert before each column in the nested component. |