Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum

CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • LoadProperty not converting null to empty string?

    rated by 0 users
    Not Answered This post has 0 verified answers | 2 Replies | 0 Followers

    Top 10 Contributor
    4,106 Posts
    Andy posted on Sun, Apr 29 2012 12:51 PM

    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.

    All Replies

    Top 50 Contributor
    161 Posts

    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.


    Don't forget to verify the post(s) that best answers your question!

    .NET Developer @ http://www.sybiz.com.au

    Top 10 Contributor
    4,106 Posts
    Andy replied on Tue, May 1 2012 5:55 PM

    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.

    Page 1 of 1 (3 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems