Hello

I want to do  as more as possible using mapping by code using convention.

When i use table per subclass strategy for mapping inherited classes i can 
define
Table name, PK column name, FK derived -> base in 
mapper.BeforeMapJoinedSubclass
An i do this like
mapper.BeforeMapJoinedSubclass += (mi, t, map) =>
{
    string tn = TableNameByEntityName(t.Name);
    map.Table(tn);

    map.Key(cm =>
    {
        cm.Column(PKNameForEntity(GetRootEntityType(t.BaseType).Name));
        cm.ForeignKey(String.Concat("FK_", tn, "_2_", 
TableNameByEntityName(t.BaseType.Name)));
    });
};
It is enough and there is no need to define something in explicit mapping.
The same i can do in other events when mapping details collections.

But when i want split column for my root class, now I have to do something 
like

public class MyEntityMap : ClassMapping<MyEntity>
{
    public MyEntityMap()
    {
        ........

        Join("G1", jm =>
        {
            *MappingConvention.ConfigureSplit("G1", jm);*  //Explicit  call 
for applying convention
            jm.Property(x => x.JoinedStr);
        });
    }
}

And in my helper class:
public static void ConfigureSplit<T>(string splitGroupId, IJoinMapper<T> 
joinMapper) where T : class
{
    var t = typeof(T);
    var tn = String.Concat(TableNameByEntityName(t.Name), "_", 
splitGroupId).ToUpperInvariant();

    joinMapper.Table(tn);

    joinMapper.Key(km =>
        {
            km.Column(PKNameForEntity(t.Name));
            km.ForeignKey(String.Concat("FK_", tn, "_2_", 
TableNameByEntityName(t.Name)));
        });
}

I want not to call MappingConvention.ConfigureSplit("G1", jm) in explecit 
mapping
but has event like 
mapper.BeforeMapSplitedGroup += (mi, t, map) =>
{
  //where map is IJoinMapper<T>
  //and it can be usefull to have access to split-groupId name via 
IJoinMapper interface for defining table name
}

It will be analogical to subclasses and detail collections mapping.

Is such description will be enough for JIRA ticket?

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/nhusers/-/Vn5R_XYNksYJ.
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/nhusers?hl=en.

Reply via email to