Quantcast
Channel: CSLA .NET
Viewing all articles
Browse latest Browse all 764

SafeDataReader returning null values?

$
0
0

I had assumed that SafeDataReader would convert any null strings coming from SQL Server into String.Empty.

But after finding some app exceptions logged, I have confirmed that null values from the database are being set to Nothing (vb.net) in their properties. I don't want to have to deal with null/Nothing in string properties.

Am I doing something wrong?

The code I am using was generated by CodeSmith, using encapsulated implementation. It uses a SafeDataReader, and in this case it passes it to a Map routine.

Something like this:

LoadProperty(_LongDescriptionProperty, reader.Item("LongDescription"))

Will break my app if I try something like:

Foo.LongDescription.Trim, because it will throw an exception.

Am I doing something wrong? I'd hate to have to write a bunch of code to check for null values, and convert them to empty strings.

Thanks.

FWIW, I'm a longtime user of CSLA (since VB6 days). Not on every project, but on quite a few, in different industries. It's a great tool.

 

 


Viewing all articles
Browse latest Browse all 764

Trending Articles