BOM-generated bug with FieldChangingEvents and Nullable Fields


Author
Message
Kirk M Sherhart
Kirk M Sherhart
StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)
Group: Forum Members
Posts: 41, Visits: 259
If a field has a Null Type of "Return and Set Alternate on Null..." and the Property Changing Events (either single or multiple) are generated, then the following code is generated.



public System.String FIELD1

{

get

{

object loValue;

loValue = this.CurrentRow["FIELD1"];

if (loValue == DBNull.Value)

{

return "";

}

else

{

return (System.String)loValue;

}

}

set

{

MyBOFieldChangingEventArgs e = new MyBOFieldChangingEventArgs(MyBOFieldNames.FIELD1, value);

this.OnFieldPropertyChanging(this, e);

if (value != "") <=== w00t*** Note: e is not used!!!! ***

{

this.CurrentRow["FIELD1"] = value;

}

else

{

this.CurrentRow["FIELD1"] = DBNull.Value;

}

}

}





The e.FieldValue is not used after returning from the event!!!! The e.FieldValue should be cast/set to value (as it is if the field is not nullable.)
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Do you get a different result if you return and test for string.empty instead of "" ?
Kirk M Sherhart
Kirk M Sherhart
StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)
Group: Forum Members
Posts: 41, Visits: 259
The result is the same if the null-replacement value is "" or String.Empty



The problem is that e.FieldValue is not used after the return from OnFieldPropertyChanging (like it is for a non-nullable field). If OnFieldPropertyChanging changes the value in e.FieldValue, it is not used to set the field value.
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)Advanced StrataFrame User (926 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
What are you using for an alternate return value in the bo mapper?
Kirk M Sherhart
Kirk M Sherhart
StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)
Group: Forum Members
Posts: 41, Visits: 259
Just tried to see if the problem was fixed under 1.7. No change. Too bad.
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Apparently this missed the list.  Changing it right now so it is sure to be in the next update.
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Fixed.  It will be in the next update.  If you want this assembly, let me know and I will send it to you.  We hope to post a minor update pretty quickly, so either way is good with me. Smile
Kirk M Sherhart
Kirk M Sherhart
StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)
Group: Forum Members
Posts: 41, Visits: 259
Thank you! I can wait for the next release.
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