Thanks Eric,
Just as you replied, on a hunch, I tried using separate automap
overrides for my Manager and Client classes to achieve those custom
mappings (rather than putting them in the Business override), and it
seems to have solved my problem (though I still have other issues with
my mappings).
For others who are interested: You must use separate overrides for
your subclasses like so:
public class ManagerMap : IAutoMappingOverride<Manager>
{
public void Override(AutoMapping<Manager> mapping)
{
mapping.HasManyToMany<Client>(x => x.Clients)
.Table("ManagersToClients")
.ParentKeyColumn("ManagerFk")
.ChildKeyColumn("ClientFk")
.Inverse();
mapping.HasMany(x => x.FullyManagedClients)
.KeyColumn("PrimaryManagerFk")
.Inverse();
}
}
- Chris F.
On Jan 26, 8:33 pm, Eric Ridgeway <[email protected]> wrote:
> Have you moved to using subclassmap<T> ? See ang3lfir3.wordpress.com for
> more info.(sorry emailing from my phone)
>
> On Jan 26, 2010 3:16 PM, "Chris F" <[email protected]> wrote:
>
> Hi all,
>
> I have abstract Business, with concrete Manager and Client inheriting
> from Business in table-per-subclass form.
>
> My pre 1.0 RC code had an automap override for the Business entity
> like so:
>
> /* Manager Joined Subclass */
> mapping.JoinedSubClass<Manager>("BusinessId")
> .HasManyToMany<Client>(x => x.Clients)
> .WithTableName("ManagersToClients")
> .WithParentKeyColumn("ManagerFk")
> .WithChildKeyColumn("ClientFk")
> .Inverse();
>
> // Necessary, HasMany convention does not run for this entity
> mapping.JoinedSubClass<Manager>("BusinessId")
> .HasMany(x => x.FullyManagedClients)
> .KeyColumnNames.Add("PrimaryManagerFk")
> .Inverse(); // Forward relationship is automapped
>
> /* Client Joined Subclass */
> mapping.JoinedSubClass<Client>("BusinessId")
> .HasManyToMany<Manager>(x => x.SecondaryManagers)
> .WithTableName("ManagersToClients")
> .WithParentKeyColumn("ClientFk")
> .WithChildKeyColumn("ManagerFk");
>
> This worked fine. It created the correct bags in the joined-subclass
> definitions, with correct name, table, and key column attributes along
> with correct many-to-many column names.
>
> Now, in 1.0 RTM code, I tried simply modifying the above code to match
> the correct method calls (like WithTableName -> Table). It executes
> but produces incorrect mappings. For example, the Manager Joined
> Subclass output has a table attribute in the bag that is wrong for the
> many-to-many. Meanwhile, what should be the one-to-many with key
> column "PrimaryManagerFk", is mapped as an incorrect many-to-many as
> well.
>
> What's changed? Thanks.
>
> Note: I am not using the 2 ManyToMany conventions at this point to try
> and get my system up and running.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Fluent NHibernate" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<fluent-nhibernate%[email protected]>
> .
> For more options, visit this group
> athttp://groups.google.com/group/fluent-nhibernate?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Fluent NHibernate" 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/fluent-nhibernate?hl=en.