Thanks a lot, about BelongsTo Unique,
if I want this situation:
public class Computer
{
....bla...
[HasMany]
public IList<InstalledSoftware> InstalledSoftware {get;set;}
}
public class InstalledSoftware
{
...bla...
[BelongsTo]
public Computer Computer {get;set;}
[BelongsTo(Unique=true)]
public Software Software {get;set;}
}
public class Software
{
...bla...
[Property(Length=300)]
public string Name {get;set;}
}
A computer can have many software installed, but obviusly not two same
software (I shouldn't reference 2 times SoftwareInstalled with same
software id). Should I handle it by myself or is ok written in this way?
Obviusly if I have a different computer, I can have same software
installed of another computer!!
Il 19/02/2011 11.53, Markus Zywitza ha scritto:
> 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.