Fluent NHibernate: rarely used properties as a component or in a separate table?

I wonder if you can help me with something I was thinking about. Say we have an Essence. Let's say that endtity has an ExtendedInfo object that contains various properties that are not often used.

I am wondering what is the best way to structure this for FNH. The easiest way to do this, I suppose, is to simply install UserInfo as the Fluent Nhibernate 'component of the User object so that it is displayed as columns in the User table.

However, since it is not used very often, perhaps it is better to store it in a separate table and lazy load if necessary? My best guess on how to do this would be to use .HasOne matching, but I don't know if this is the best approach.

Any thoughts on how best to go here?

thanks

+3
source share
1 answer

Design problem:

Matching this as a component is easier to handle, the database schema is simplified and handles this class.

When you match it many-to-one, it needs an identifier. When other types also use this UserInfo, they need to save it in the same general table. In any case, you must ensure that the same instance is UserInfonot used by multiple owners. This is not possible with components; you cannot share UserInfo.

Performance issue:

, . , , . UserInfo , , , .

, NH UserInfo . , , UserInfo , . ( join), NH . , .

:

(--) - . , (!) Users , UserInfos.

+2

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


All Articles