Hello,

I have 3 tables:

TUser(PK int id, string name, ...)
TGroup(PK int id, string name, ...)
TRole(PK int id, string name, ...)

plus a 4th one that associates them:

TUserGroupRole(FK int userid, FK int groupid, FK int roleid)

I have 3 types in my model :

User, UserGroup, and UserRole

I want User has an IDictionary<UserGroup,UserRole> to handle its roles
by group:

public class User
{
    public int Id{get;set;}
    public IDictionary<UserGroup, UserRole> Roles {get;set;}
}

Using XML mapping, I achieved that with a <map> element, like so
(pseudo mapping):

<map name="Roles" table="TUserGroupRole" sort="unsorted">
    <key column="userid"/>
    <index-many-to-many column="groupid" class="UserGroup"/>
    <many-to-many column="roleid" class="UserRole"/>
</map>

But I didn't manage to configure my mapping using FluentNhibernate. I
tried:

HasManyToMany(u => u.Roles).WithTableName("TUserGroupRole")
    .WithParentKeyColumn("roleid")
    .WithChildKeyColumn("userid")
    .AsMap("groupid");

but then I got a mapping exception:

"System.Xml.Schema.XmlSchemaValidationException: The element 'map' in
namespace 'urn:nhibernate-mapping-2.2' has invalid child element
'many-to-many' in namespace 'urn:nhibernate-mapping-2.2'. List of
possible elements expected: 'map-key, composite-map-key,
map-key-many-to-many, index, composite-index, index-many-to-many,
index-many-to-any' in namespace 'urn:nhibernate-mapping-2.2'."

Any help on this point would be appreciated.

Thank you very much,

Romain


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to