Hi
Consider this:
DB:
I have a table with a column (varchar) called Address (allow null is false).
Code:
I do not set the Address field (it is "") and when I try to save the entity I get an "Column does not allow nulls" error?!
You could argue that an empty string is the same as null. But consider this:
DB:
On the same table I have another column (bit) called MemeberOfGameClub (allow null is false).
Code:
I set the MemeberOfGameClub to True and save works fine. But when I leave it untouched or set it to false I get the same error ("Column does not allow nulls")
It seems that LLBL tries to save a nothing/null to the database when the data is untouched (not changed) in my code.
A fix could be to setup at default value in the DB and when LLBL tries to save a null then the default value will be used instead. But I do not like that solution - and I am wondering why LLBL converts a “” (or false) to null!???
I use LLBL version 2.6 and MS SQL Server 2005.
Her is some real-word info:
Code (save):
adapter.SaveEntityCollection(sitesChanged, True, False)
Exception:
Failed SaveSiteToVP2009Test HumanResources.Test Test method HumanResources.Test.PackageManagerTest.SaveSiteToVP2009Test threw exception:
SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException: An exception was caught during the execution of an action query:
Cannot insert the value NULL into column 'ISOCountryName', table 'VestasPeople2009.dbo.Site'; column does not allow nulls. INSERT fails.