﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Null-value mishandled in BOM-generated code</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Sun, 20 Sep 2026 14:58:14 GMT</lastBuildDate><ttl>20</ttl><item><title>Null-value mishandled in BOM-generated code</title><link>http://forum.strataframe.net/FindPost22626.aspx</link><description>I have a simple table with a nullable numeric field JOB_TYPE, which BOM sees as a System.Decimal value.  If I set BOM to use "Nullable Generics" AND to create property accessing event for the field, I get the following BOM-generated code for the field accessor&lt;br&gt;
[code]        public Nullable&amp;lt;System.Decimal&amp;gt; JOB_TYPE&lt;br&gt;
        {&lt;br&gt;
            get&lt;br&gt;
            {&lt;br&gt;
                object loValue;&lt;br&gt;
                PeopleBOFieldAccessingEventArgs e;&lt;br&gt;
                Nullable&amp;lt;System.Decimal&amp;gt; loReturn;&lt;br&gt;
                loValue = this.CurrentRow["JOB_TYPE"];&lt;br&gt;
                if (loValue == DBNull.Value)&lt;br&gt;
                {&lt;br&gt;
                    loReturn = (Nullable&amp;lt;System.Decimal&amp;gt; )null;&lt;br&gt;
                }&lt;br&gt;
                else&lt;br&gt;
                {&lt;br&gt;
                    loReturn = new Nullable&amp;lt;System.Decimal&amp;gt; ((System.Decimal)loValue);&lt;br&gt;
                }&lt;br&gt;
                e = new PeopleBOFieldAccessingEventArgs(PeopleBOFieldNames.JOB_TYPE, loReturn);&lt;br&gt;
                this.OnFieldPropertyAccessing(this, e);&lt;br&gt;
                return new Nullable&amp;lt;System.Decimal&amp;gt; ((System.Decimal)(e.ValueToReturn)); &lt;===BOOM!&lt;br&gt;
            }&lt;br&gt;
            set&lt;br&gt;
            {...}&lt;br&gt;
[/code]&lt;br&gt;
If JOB_TYPE is null, loReturn becomes a null of type decimal?, but is cast (boxed) into a null of type object for the eventargs.  After the event is processed (there is no code in the event itself), the value of e.ValueToReturn is a null of type object, which causes the exception when attempting the cast to System.Decimal.&lt;br&gt;
&lt;br&gt;
If this a "bug" or "feature"?</description><pubDate>Wed, 08 Apr 2009 09:15:16 GMT</pubDate><dc:creator>Kirk M Sherhart</dc:creator></item><item><title>RE: Null-value mishandled in BOM-generated code</title><link>http://forum.strataframe.net/FindPost22677.aspx</link><description>I have not yet had a chance to look at this...sorry for the delay.&amp;nbsp; I have added it to the list, so we are making progress! :)&lt;/P&gt;&lt;P&gt;The last two weeks have been crazy busy around here....so sorry for the delay.</description><pubDate>Wed, 08 Apr 2009 09:15:16 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Null-value mishandled in BOM-generated code</title><link>http://forum.strataframe.net/FindPost22658.aspx</link><description>Hi Trent&lt;br&gt;
&lt;br&gt;
I've attached some code/text that illustrates the problem.  I created a simple, 2-field table with a single record of value (1, null).  I generated the BO (see included BOM properties screenshot, etc.)  I've included the BOM-generated code for the object.  I created a simple form with a button that executes the included code (a simple retrieval and access of the nullable field value.)  Clicking the button causes the BOM-generated code for the NULL_TEST_VALUE field accessor to throw a NullReferenceException.&lt;br&gt;
&lt;br&gt;
Hope this helps you to track down the problem.</description><pubDate>Mon, 06 Apr 2009 09:59:04 GMT</pubDate><dc:creator>Kirk M Sherhart</dc:creator></item><item><title>RE: Null-value mishandled in BOM-generated code</title><link>http://forum.strataframe.net/FindPost22640.aspx</link><description>Please send me a sample.&amp;nbsp; Not able to reproduce in the same fashion.&amp;nbsp; A workaround in any case is to get this the way that you like then go back into the BO mapper and use a Custom Code option.&amp;nbsp; Paste the adjusted code into the Customer Code section so that when the BO is rebuilt through the mapper your changes don't get overwritten.&amp;nbsp; But I would still like to see a sample when possible.</description><pubDate>Sat, 04 Apr 2009 13:01:54 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>