Finally I got to write few things about my ongoing work. I am not sure that this is completely correct and how it should be done.
I need to write a really simple tracking application and I decided to use Boo and Castle to both finish the task and to learn those two exciting technologies.
There is a simple inheritance structure in the project and few relationships and so I have finished with these two simple rules to follow:
1. generics is better so do not try to define your own base class. Use
[Castle.ActiveRecord.ActiveRecord]
class Event(Castle.ActiveRecord.ActiveRecordBase of Event):
2. if there is HasMany/BelongsTo relationship, use:
_expenses as IList = ArrayList()
[Castle.ActiveRecord.HasMany(Expense, Table:"Expense", ColumnKey:"accountid", Inverse:true) ]
Expenses as IList:
get: return _expenses
set: _expenses = value
on the "parent" side and
_fromAccount as Account
[Castle.ActiveRecord.BelongsTo("accountid")]
FromAccount as Account:
get: return _fromAccount
set:
_fromAccount = value
_fromAccount.Expenses.Add( self )
on the other. This way it works the way I like: setting Account property but being able to read list members at the same time.
Žádné komentáře:
Okomentovat