بین دو Entity میتوان رابطه یک به یک برقرار کرد. یعنی به ازای یک instance (رکورد) از یکی، فقط و فقط یک instance (رکورد) در دیگری وجود داشته باشد. هر چند که NH این نوع رابطه را نشانه طراحی بد میداند، اما دو راه برای پیادهسازی آن مهیا کرده است: ۱- روش primary key associations: …
NHibernate have 2 varieties of one-to-one association, primary key associations and unique foreign key associations. Castle ActiveRecord documentation describes just first varity, primary key associations. But how about second variety, unique foreign key associations? Well, it can be implemented as follow. Please notice sample: [ActiveRecord(Lazy = true)] public class User : ActiveRecordBase { [PrimaryKey] …
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 …