Create ID from seed table in Fluent NHibernate

I need to create an identifier from a column in the visit table and increase the value in this column.

eg

Seed Table:

name     "analysisid"
id       1


Analysis Table:

id
name
description

When comparing the analysis, I need to make sure that the identifier is taken from the seed table, and when the analysis is inserted, the analytical testis is updated. Am I implementing my own class inheriting from TableGenerator?

+3
source share
1 answer

NHibernate includes a number of identity generation strategies and includes an extension mechanism for custom through NHibernate.Id.IIdentifierGenerator.

, insert, . <generator class="trigger-identity" />.

IIdentifierGenerator <generator class="My.Namespace.MyIdentifierGenerator" />.

, :

Id( x => x.Id ).GeneratedBy.Custom<NHibernate.Id.TriggerIdentityGenerator>();
Id( x => x.Id ).GeneratedBy.Custom<My.Namespace.MyIdentifierGenerator>();
+4

Source: https://habr.com/ru/post/1735409/


All Articles