What causes "Invalid nn index for this SqlParameterCollection with Count = nn" when the column is Null in the database?

For the Placement object, we have two columns with a zero value: CollectionTypeand AccommodationUnitType.

However, in the data, I noticed that they were set to zero and not to zero, as a result of which NHibernate tried to find the object with identifier 0. It was a lot of extra unnecessary DB calls, so I updated the corresponding data to NULL in the database, and suddenly I get a big fat error:

"Invalid index 24 for this SqlParameterCollection with Count = 24"

Here is an override of the mapping I'm using:

    public void Override(AutoMapping<Core.Entities.Itinerary.Accommodation.Accommodation> mapping)
    {
        ...
        mapping.References(x => x.CollectionType).Nullable();//.Not.LazyLoad();
        mapping.References(x => x.AccommodationUnitType).Nullable();//.Not.LazyLoad();
        Cache.Is(c => c.ReadWrite());
    }

There are many answers on Google that seem to have nothing to do with my problem.

Any ideas?

Edit , :

public virtual AccommodationUnitType AccommodationUnitType { get; set; }
public virtual AccommodationCollectionType CollectionType { get; set; }
+4
1

"CollectionType" "AccommodationUnitType" "int"?

"int?".

, , , - .

public virtual int? CollectionType {get;set;}
public virtual int? AccommodationUnitType {get;set;}
+5

All Articles