Dynamic mapping of NHibernate / Fluent NHibernate columns

I have a table in which some of its columns are unknown at compile time. Such columns can have either an integer value or some Enum value. There is a table that contains all the names of such dynamic columns, and also contains the column type. This "metatable" has the following columns:

  • DynamicColumnId (Pk)
  • Name
  • TypeId (Integer / Enum, like Fk from a separate table)

Integer columns have a name from this table, while Enum columns are Fk columns from a table with this name with some modification (for example, the "DynamicTable" prefix).

The only solution I could think of in this situation is to use Reflection.Emit to dynamically create the Entity class and the corresponding Mapping class. Admittedly, I'm new to NHybernate / Fluent NHybernate, and it seems like a relatively simple hierarchy between tables, so I wanted to check that my solution is not as ugly as it initially appears ...

I would also welcome solutions that completely ignore my table hierarchy in order to efficiently perform the same results (i.e. enumerate rows in a dynamic table, iterate over all columns, knowing if they are enumerations and, if so, their possible values).

(: re ) , , Too-Much-Info. , .

. /, = > = > , Iron Python, , . "", . "" "", "" .. , - Python, ( , ). / . , , , , . , , , ​​ . " " - , (), , , .

+3
1

, , , Redis , CouchDB SQL. , RDBMS, NHibernate (DynamicColumnId, Name, TypeId), , .

0

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


All Articles