I think the issue here is the approach.Firstly ElementType would have to be
Roles not an int if this were what you're trying to do.
Secondly, I'm not sure you really are accomplishing what you want with that
class structure.
>From a SQL perspective you'd have to have a "PersonDetail" table or "Roles
For Person" table.example:

id | personid | Role |
1 | 2            | Administrator (could also just be a 1 or 2 depending on
your preference)
1 | 2            | User

Then when you query you'd ask for "Person 2's Roles".
Ultimate your issue is a SQL schema issue as opposed to how ActiveRecord
works or doesnt.



On Tue, Jun 2, 2009 at 9:24 AM, CVertex <[email protected]> wrote:

>
> Hi Markus,
>
> Are you saying what I'm asking is not possible? Or are you agreeing
> with Jonathon? I was confused as you responded to Jonathon.
>
> I tried setting ElementType = typeof(int), but it threw the same
> exception, so I'll assume you agreed with Jon.
>
> Thanks,
> CV
>
>
>
> On Jun 2, 3:58 am, Markus Zywitza <[email protected]> wrote:
> > Not really, you can also use collections of simple types etc. Check
> > the Element and ElementType properties of the HasMany-attribute.
> >
> > -Markus
> >
> > 2009/6/1 Jonathon Rossi <[email protected]>:
> >
> > > Role would have to be an ActiveRecord class to be used with HasMany.
> >
> > > Think about how you'd do this in the database. The first case works
> because
> > > it is just a column in the Person table storing a single int or string
> for
> > > the enum value.
> >
> > > On Mon, Jun 1, 2009 at 1:22 AM, CVertex <[email protected]>
> wrote:
> >
> > >> I have a role enum
> > >> public enum Role
> > >>    {
> > >>        User,Administrator
> > >>    }
> >
> > >> And I can add a property to a record type,
> >
> > >> [ActiveRecord]
> > >> public class Person{
> > >>        [PrimaryKey(PrimaryKeyType.Identity)]
> > >>        public virtual int Id { get; set; }
> >
> > >>        [Property()]
> > >>        public virtual Role PersonRole { get; set; }
> >
> > >> }
> >
> > >> but how do I add a property of IList<Role> to Person to represent a
> > >> Person having many Roles?
> >
> > >>        [HasMany]
> > >>        public virtual IList<Role> Roles { get; set; }
> >
> > >> when I run this, I get
> >
> > >> "ActiveRecord tried to infer details about the relation Person.Roles
> > >> but it could not find information about the specified target type
> > >> Kk.Console.Role. If you have mapped a Collection or Dictionary of
> > >> value types, please make sure you have specified the Table property."
> >
> > >> Is this something I can model in AR?
> >
> > > --
> > > Jono
> >
>


-- 
Ryan Svihla
Systems Developer
Farm Bureau Bank

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to