Null handling in the UpdateFactory

Topics: General Discussion Forum, July and December Releases Forum
Apr 16, 2007 at 7:57 PM
Hi,

I've experienced an issue with an update stored procedure. Using the recipe to create the update via the Repository i noted that the update factory class contains code like the following:

if (postcode.NHSCode != null)
{
db.AddInParameter(command, "NHSCode", DbType.String, postcode.NHSCode);
}

This leads to an exception being thrown when the business entity passed in has null as the value as the SP is not provided with the parameter it expects. Is this the expected results??? This has meant i've had to manually edit those update factory classes where passing a null into the SP is acceptable.

Cheers,

Wes
Developer
Apr 19, 2007 at 5:01 PM
If you want to avoid adding the not null check, then you should specify a property that is a value type and is marked as nullable (Is Nullable setting unchecked) otherwise you will always get that check. In case you cannot meet these requirements, then you can update the t4 file (EntityUpdateFactory.t4) located under Data Access GP root folder\Templates\T4\DAC. You don't need to recompile/publish the package, just simply update the file removing the check (line 77 changed to "if (false) {" or any other condition that apply)