You're already on the right track. It's BelongsTo at Player and nothing at Role. For the other scenario, you simply have to make the BelongsTo unique.
-Markus 2011/2/18 Francesco Belladonna <[email protected]>: > Sorry for long title, the question is rather simple: > > I have 2 classes, Player and Role (they are activerecord table) > > class Player > { > ...Various fields... > > [BelongsTo("RoleId")] > public Role Role {get;set;} > } > > class Role > { > ...Various fields... > > [Property] > public string Name {get;set;} > } > > A Player, can have only one role, but (for me), it doesn't matter if > Role has 0-1-2-many players, so I would like to omit HasMany attribute > (my example is easy, but my database is much bigger than this). Role is > behaving like a user-defined enum, is possible to do this? Which is the > correct way? > > P.S. > What if I have a similar situation but I need that a Role belogs only to > one player (onetoone), but again I would like to omit the part from the > "Role" class (so role doesn't know anything about this association) > > -- > You received this message because you are subscribed to the Google Groups > "Castle Project Development List" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/castle-project-devel?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Castle Project Development List" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/castle-project-devel?hl=en.
