NULL management

Feb 27, 2016 at 4:29 PM
I think you'll start to hate me :)

I've been playing with my tables, what if I have to insert an empty string into database ? For what I've seen the empty string is translated to a NULL but I have some string that must be empty in code a not null in db.

Feb 27, 2016 at 5:28 PM
Edited Feb 27, 2016 at 6:50 PM
don't worry, I don't hate you, the opposite - I really value your feedback. I know, real life apps we often inherit are full of strange and even stupid arrangements, and framework's quality is ability to accommodate all this stuff and work around them. Not just build a stupid demo app from scratch in 5 minutes, in the way you like it (like it happens in EF presentations), but to work over old and ugly pile of 'stuff'.
You and other guys provide a fresh stream of 'special' cases, and it is extremely valuable. So, stay with me, we gonna crack it.
I will look at Nulls. I guess this (replacing empty with null) was done as extra convenience, to automatically handle ambiguity, but if you don't need it - there must be a way to turn it off.
Feb 29, 2016 at 12:36 AM
can't repro it, empty string goes as-is. Try the following:
in the BookStore project, file BookExtensions.cs, method NewAuthor, change assignment to Bio:
  auth.Bio = bio ?? string.Empty;
then run Extended unit tests and look in the database at table Author - Bios are empty strings; play with and without change, you'll see NULL or empty string