c# - Sorted list in NHibernate without sequential numbers -


i have sorted list in class foo. read index column have sequential , start in 0 , 1, 2, 3, 4, 5...

in case, in order column have 0, 1, 2, 5. foo objects have list length of 6. positions 3 , 4 null.

this map

<list name="bars" cascade="all-delete-orphan">   <key column="foo_id" />   <index column="order" />   <one-to-many class="bar" /> </list> 

how can rewrite map in order remove null positions?

i had similar situation due legacy concept adopted in our tables: our index column starts in 1, remaining nasty null value in position 0 when retrieve collection list.

the solution our case use these collections iset instead.

to keep order, put order-by attribute in our mappings, , control index persistence ourselves.

using example, become:

<set name="bars" cascade="all-delete-orphan" order-by="order">   <key column="foo_id" />   <one-to-many class="bar" /> </set> 

ps: don't forget change collection variable type iesi.collections.generic.iset(of bar)


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -