Hello,
I've got some problems with one-to-many mappings, seems like
KeyColumnNames naming convention works not as expected. But probably I
am doing something wrong.
Let's say we have a bidirectional one-to-many mapping, e.g. (Parent)-
hasMany-(Child).
We need to define key column name at both sides of the mapping. I have
the following key column name conventions
// in a IHasManyConvention implementation
public void Apply(IOneToManyPart oneToManyPart)
{
oneToManyPart.KeyColumnNames.Clear();
oneToManyPart.EntityType.Name + "Fk"
}
// in a IReferenceConvention implementation
public void Apply(IManyToOnePart manyToOnePart)
{
manyToOnePart.ColumnName(manyToOnePart.Property.Name + "_Id");
}
So, this conventions work properly in cases if Property name is the
same as the Parent class name (in this case
EntityType.Name==Property.Name). But often it is not true, and in that
cases the mapping will expect child table to have two different key
columns, which is definetly wrong. In this case we need to use
IAutoMappingOverride and specify the correct key column name for this
particular entity.
I did it successfully in prev versions of FNH, where we had
WithKeyColumn() method. But currently it is not working. I debugged
and found, that for some reason naming convention is applied AFTER the
appropriate override.
Because my oneToMany convention has KeyColumnNames.Clear(); method
call, so all custom overrides are cleared and ignored. Probably this
is incorrect and I need to fix it, but anyway, word "override" usually
means that something is applied after or instead the default behavior,
not before it :)
Am I doing something wrong, or is it a bug in FNH, or something?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---