LoadProperty not converting null to empty string?

LoadProperty not converting null to empty string?

Old forum URL: forums.lhotka.net/forums/t/11338.aspx


ajj3085 posted on Sunday, April 29, 2012

I'm having a problem which is a bit unexpected.  Basically, I'm using a command object to get some data from a SQL database.  The command object uses registered properties, one of which is a string.  The column in the database is nullable, and so LoadProperty is sent a value of null via the property setter.

However, when I get the property using ReadProperty, I'm actually getting null back, which I didn't think Csla did in the case of a string.  I'm used to it returning string.Empty.

This happens through several other objects as well, as one object reads the property from the command object, and that object's property is in turn read in another BO.  All the will, the null value is copied and return from Read/Get property as null instead of string.Empty.

Has something changed in this regard, or is this a bug?  I'm using Csla 4.1.0.

Marjon1 replied on Sunday, April 29, 2012

It is the ExtendedSafeDataReader that converts nulls into empty strings, not the FieldManager LoadProperty methods.

If you can post some of the code that is being used, may be able to show exactly where the problem lays.

 

ajj3085 replied on Tuesday, May 01, 2012

I don't recall this being the case. It may not have been LoadProperty, it may have been Read/Get property, but I'm fairly sure that null values for strings were returned as string.Empty all the time.  The reason was that, irrespective of how the BO may have been loaded, if null were returned it would blow up WinForms databinding, so string.Empty was always returned in this case instead to prevent this.

Copyright (c) Marimer LLC