BelongsTo is a attribute in Castle ActiveRecord that is used to mark an association as many-to-one. For example consider following class diagram. There is an association between Student and Teacher named ArtStudent. This is a many-to-one association so you must add BelongsTo attribute to Student class as showed in following code snippet.
[ActiveRecord(Lazy = true)]
public class Teacher : ActiveRecordBase
{
//other properties
}
[ActiveRecord(Lazy = true)]
public class Student : ActiveRecordBase
{
[BelongsTo("ArtTeacher_ID", Cascade = CascadeEnum.None)]
public virtual Teacher ArtTeacher { set; get; }
//other properties
}
As this is an one-way association from Student only, Teacher does not know anything about student so it not necessary to add any association or property to Teacher.
Using Cascade field of BelongsTo attribute you can tell ActiveRecord what to do if any modifications occurs to Student. These modification can be SaveUpdate and/or Delete. Please take attention that means modifications just for Student not Teacher. For example if you have had set cascade mode to CascadeEnum.Delete, whenever the Student is deleted, its associated Teacher will be deleted too, but if a Teacher is deleted, no Student will be deleted.
More documentation about BelongsTo attribute:
1. BelongsToAttribute API Document (Trunk)
2. BelongsToAttribute API Document (RC1)
3. BelongsToAttribute Class
4. BelongsToAttribute Members
5. CascadeEnum Enumeration