I'm working on a project that's written in C# and uses Fluent NHibernate. I'm getting the infamous exception "Invalid index X for this SqlParameterCollection with Count X". I've tried several suggestions from different SO solutions, but I just can't find the mapping problem.
The error never happens when reading data, only when updating. The table being updated is pretty simple so the map for that table is also simple. When the update happens, NHibernate constructs a simple one table update query, so there's not a lot actually happening when the error occurs.
My update code is wrapped in a transaction
using (var tx = Session.BeginTransaction())
{
try
{
result = PerformUpdate(obj, modifiedBy);
if (result.Succeeded)
{
tx.Commit();
Session.Flush();
}
else
RollbackTransaction(tx);
return result;
}
catch (Exception ex)
{
tx.Rollback();
throw;
}
}
}
The exception gets thrown on the tx.Commit().
I'm fairly confident that this is a mapping problem somewhere in the schema, but I can't find it. How do I inspect the list of SqlParameters so I can debug this? There has to be a way to inspect the list of SqlParameters so I can see what doesn't belong.