Fluent NHibernate OptimisticLock.None() causes “The string 'none' is not a valid Boolean value.”
-
24-09-2019 - |
Question
I'm using the following mapping:
public class LoadMap : IAutoMappingOverride<Load> {
public void Override(AutoMapping<Load> mapping) {
mapping.HasMany(x => x.Bids).OptimisticLock.None();
mapping.Version(x => x.Version);
}
}
But when I try to create the session I get the following exception:
[FormatException: The string 'none' is not a valid Boolean value.]
[XmlSchemaValidationException: The 'optimistic-lock' attribute is invalid - The value 'none' is invalid according to its datatype 'http://www.w3.org/2001/XMLSchema:boolean' - The string 'none' is not a valid Boolean value.]
I'm using NHibernate 2.1.2.4000 and I was using Fluent NHibernate 1.0RTM, but tried the latest build 636 just to be sure this isn't something that was fixed recently or something.
As a side note, in case I'm doing this all wrong, I would like to be able to make changes to the .Bids list without incrementing Version. I saw an example on Ayende's blog that did what I wanted with properties.
Solution
I think it's a bug. Valid values for the optimistic-lock property are true|false, as you state in your comment. It appears that Fluent NHibernate is setting the property to none but I would generate the XML schema to be sure.
OTHER TIPS
As Jamie says, looks like a bug (or missing feature) in Fluent NHibernate. I've added a hack to allow setting False and True on OptimisticLock in my github fork. It seems to work.