Open hazzik opened 5 years ago
I think this should be decided by the programmer as a configuration, Nhibernate is defining a decision that should be of architecture. I think this has already caused a lot of bugs and a headache in the programmers code and code succession. Needing to create hacks on code. A configuration returning a Default(T) when all the properties are null is possible?
Any more guidance on this issue? I would be fine with a configuration setting that returns an empty collection instead of a null.
As it is now I am way behind the latest release because I don't have the resources to patch and test every update. I am going to go ahead and patch 5.3.6 for now.
If all the columns in a dynamic component are null, then rather than returning an IDictionary with keys and null values, it just returns a null reference. Having even one column with a non-null value will cause the dictionary to be populated.
This causes two problems: first is you have an unexpected null reference, and if you want to create a dictionary you won't know what keys to add to it. Second, if you do add a reference to a dictionary with the correct keys, NHibernate will attempt to INSERT rather than UPDATE. This will either cause a duplicate record or a primary key violation.
Originally posted by @czema in https://github.com/nhibernate/nhibernate-core/pull/2027