开发者

Prefix string to ALL generated table names - FluentNHibernate

Is there a simple way to prefix all generated table names with a string?

The convention

Table.Is(x => "Prefix" + x.EntityType.Name)

only works for Entity tables (doesn't function for join or subclass tables)

I can't seem to find a simple way to have every single table开发者_运维百科 that nhibernate creates be prefixed with a specific string without first identifying all the cases that would create a table and specifying a rule per case. Ew!


for this you have to implement IHasManyToManyConvention and IJoinedSubclassConvention see

public class SubclassConvention : IJoinedSubclassConvention, IHasManyToManyConvention
{
    public void Apply(IJoinedSubclassInstance instance)
    {
        instance.Table("Prefix" + instance.Type.Name);
    }

    public void Apply(IManyToManyCollectionInstance instance)
    {
        instance.Table("Prefix" + instance.TableName);
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜