Null-value mishandled in BOM-generated code


Author
Message
Kirk M Sherhart
Kirk M Sherhart
StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)
Group: Forum Members
Posts: 41, Visits: 259
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

        public Nullable<System.Decimal> JOB_TYPE

{

get

{

object loValue;

PeopleBOFieldAccessingEventArgs e;

Nullable<System.Decimal> loReturn;

loValue = this.CurrentRow["JOB_TYPE"];

if (loValue == DBNull.Value)

{

loReturn = (Nullable<System.Decimal> )null;

}

else

{

loReturn = new Nullable<System.Decimal> ((System.Decimal)loValue);

}

e = new PeopleBOFieldAccessingEventArgs(PeopleBOFieldNames.JOB_TYPE, loReturn);

this.OnFieldPropertyAccessing(this, e);

return new Nullable<System.Decimal> ((System.Decimal)(e.ValueToReturn)); <===BOOM!

}

set

{...}



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.



If this a "bug" or "feature"?
Reply
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Please send me a sample.  Not able to reproduce in the same fashion.  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.  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.  But I would still like to see a sample when possible.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search