开发者

Fluent NHibernate set all IDs to assigned

I know I can manually set each Id property to assigned using Assigned().

Is there开发者_高级运维 any way of applying this globally, as I want to do it on every entity?


Sure, just register FluentNHibernate convention like this:

public class AssignedIdConvention : IIdConvention
{
    public void Apply(IIdentityInstance instance)
    {
        instance.GeneratedBy.Assigned();
    }
}

Registration goes like this:

Fluently.Configure()
    .Mappings(...)
    .Conventions.Add<AssignedIdConvention>()
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜