Skip to content

One-To-Many collection with a lot of additional null objects #3272

Answered by pasqualedante
paradox2707 asked this question in Q&A
Discussion options

You must be logged in to vote

This happens because the indexes of the elements of the list are not sequential, but there are gaps: if your index column has gaps in it (i.e. it has values like 3, 4, 5), NH would populate the resulting List with empty elements at the expected places (0,1 and 2). This behavior is by design as you can read at paragraph 6.3.2 of NH reference guide:

6.2.3. Indexed collections
All collection mappings, except those with set and bag semantics, need an index column in the collection table.
An index column is a column that maps to an array index, or IList index, or IDictionary key. The index of an
IDictionary may be of any basic type, mapped with . It can be an entity reference mapped with
(or i…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@fredericDelaporte
Comment options

Answer selected by fredericDelaporte
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #3193 on March 26, 2023 18:22.