Paul Wilson's .NET Blog

Ramblings from the Creator of WilsonDotNet.com

  • Nullable Types are NOT Integrated in .NET v2.0

    Nullable value types have been added to .NET v2.0, but they have NOT really been integrated.  The C# team has done a good job incorporating support for nullable types into the syntax, but the VB team has done nothing, which once again leaves VB behind the curve in features.  But that is not what this post is about -- this post is about the fact that nullable types have NOT been integrated into the rest of the .NET framework -- and obvious places at that.

    (1) Reading Data: Given a data reader, you can't just assign a value to a nullable type!  This one just seems incomprehensible -- nullables obviously already exist in the database, and the .NET SqlTypes support them already, so this seems to be a key integration point.  But alas, you simply can NOT assign a value from your data reader to a nullable type.  Instead, you still have to explicitly test for DBNull, and handle that case separately:
     
        int? nullInt;
        if (dataReader.IsDBNull(index)) { nullInt = null; }
        else { nullInt = dataReader.GetInt32(index); }

    Note that Julia Lerman observed this before -- see her comments for more viewpoints.

    (2) ConvertType: C# does at least support casts to/from regular types and nullable types, and it even gives you a handy way to convert nulls to a default by using the ?? operator, but just try to do any generic type conversions with Convert.ChangeType -- not supported!  Again this seems like an obvious integration point, if nullable types are to be "builtin", but once again the new nullable types just feel like an afterthought -- and NOT integrated.

    (3) WinForm Controls: The official story is that the data grids support nullable types, but what happens when you try to use a NumericUpDown or a DateTimePicker -- not supported!  That's right, once again you'll find that you still have no real integration for nulls, and you'll have to continue resorting to magic values or checkboxes and manual conversions.  These controls seem like another obvious place where there should be support for nullables.

    All of this lack of integration makes me wonder what the point of nullable types really is?  We could always create our own structs that supported the concept of null very similarly, but they lacked the builtin syntax support that C# is including, not to mention they failed to work with data-binding in grids, but the new nullable types simply aren't much better.  The one thing they have going for them is that they will at least be a "standard" nullable.

    Note that none of these issues prevented me from adding support for nullable types to my O/R Mapper, but I just thought I'd pass along what I observed since I do think the support I discovered was very disappointing.

  • Personal Update -- Progress Report on Cancer

    I've had several people ask me how my wife Jenny is doing since we found out she had breast cancer back in December, so here goes:

    Jenny had 8 treatments of chemotherapy, each one 2 weeks apart, between December and March.  The first 4 treatments caused a great deal of tiredness and weakness, and change in appetite to a lesser degree, especially during the first week.  The last 4 treatments were a different drug and caused significant bone pain and some numbness, and the pains seemed to accumulate and get worse each time.  These 16 weeks were definitely not very pleasant for Jenny, but they also weren't as bad as the chemotherapy required for some other types of cancer we've known people to have.  Then, after recovering from the chemo, Jenny went in to the local hospital last week, April 19, for her first surgery, and she came home two days later on April 21.  She was definitely in an awful lot of pain, and unable to do much of anything for a while, but she is doing very well now, with just a little pain left at this point.  Most basic things she can also do now, although she won't be able to do much lifting for some time -- and she still can't sleep in bed or a solid night in the recliner.  Next up, in a few weeks, will be radiation, which is expected to be every weekday for 5-6 weeks, which will be an annoying way to spend an hour or two every day when you consider the drive back and forth too.  Finally, later this year Jenny will finish up with another surgery or two for reconstruction, and then yet another recovery of course after that.

    Of course all I've told you so far is the technical details -- but hey, what do you expect from a technical guy.  :)  First, we were very blessed that we bought and moved into our new house, and sold our old house, before all this happened, since things would have been very different if the timing had been reversed.  Its also been great that I've been working from home with a mostly flexible schedule and a very understanding client, since I've been able to be there for Jenny at every point.  That alone I think has made things much easier and therefore made this a very doable experience for Jenny, even though its certainly not been a pleasant experience in any way.  On the down side though, this does pretty much make you put your whole life on hold for a whole year, and that means no vacations, and not much of anything else.  Its also difficult with two young kids, since they still depend on us for everything, and since they are both involved in several extra-curricular activities too.  On another positive note, everyone has been very supportive -- family, friends, and even complete acquaintances -- its actually quite amazing how people go out of their way to help.  So while things are hard at times, and our lives have been put on hold, we're still doing well in many ways, and we expect Jenny to have a long life ahead when this is all over.

    By the way, I downloaded and installed Beta 2 of VS 2005 the weekend it came out, right before Jenny's hospital stay.  That means that I was able to spend a lot of time working on extending my O/R Mapper instead of just fretting and worrying.  So right now I have a Beta of v4.0 of my O/R Mapper out there which supports .NET v2.0 Generics and Nullables, as well as having a few other new features!  I've also been getting ready to give a presentation on O/R Mapping at the upcoming Atlanta CodeCamp, which will necessarily feature NHibernate due to the credo requiring only free code.  So stay tuned for a couple of posts in the coming weeks that will feature some of what I've experienced.

  • How do you make FlexWiki readonly to Anonymous Users ?

    I've been asked to add a wiki to my sites to enable collaboration -- sounds like a great idea.  I have downloaded and played around a little with FlexWiki -- but I have one issue.  Is there any way to make it readable to anonymous users and editable only by authenticated users?  I've seen others asking this question also, but the suggested web.config solutions completely lockout anonymous users from viewing.  I'd appreciate any options, even if its another wiki solution since I see nothing special about FlexWiki.  Note that my users are in a MS Sql database and already authenticated in my main ASP.NET app -- so whatever I do should ideally work with my current users.  Thanks.

  • Visited Atlanta C# User Group

    I made it to the Atlanta C# User Group tonight -- it was a very nice meeting.  Keith Rome discussed asynchronous programming -- great job on locks and events.  I also got to catch up with a few buddies I used to work with -- Jerry Dennany and Clark Allen.  Of course I also got to say hi to everyone else -- I won't name others since I'll miss some no matter what.  Finally, I loved the new Alpharetta offices of Microsoft (its less than 30 minutes from my home), although I'm not sure why I had to buzz security to get out of the complex since I was obviously already in.

  • Enterprise Manager Tip

    This is probably common knowledge, but I didn't know it -- copy (ctrl-C) an object in Sql Enterprise Manager and paste (ctrl-V) it into a text editor to get its script!

  • WilsonORMapper v3.2.0.0 Released

    Update: WilsonORMapper v3.2.0.0 (3/30/2005) includes the following:

      The following important new feature is why this is a major update:   
    • Added IsolatedContext Property to Create New Isolated ObjectSpace
    • Use IsolatedContext to Isolate all Tracking/Caching to that Instance
      Then there are these important bug-fixes as well that were rolled in:   
    • Fixed Delete with Lazy-Loaded Many-To-Many removing Related Objects
    • Fixed StartTracking clearing any pre-existing Relations on Objects

  • WilsonORMapper v3.1.0.2 Released

    Update: WilsonORMapper v3.1.0.2 (3/25/2005) includes the following:

    • Fixed Case where Delete with Lazy-Loaded Many-To-Many Timed Out
    • Fixed GetObjectCount to Support Oracle's return of Decimal Type
    • Thanks to Jeff Lanning for substantial Performance Improvements
    • Thanks to Paul Welter for Null Byte[] and Insert of keyType=None
    • Continued to Improve Exception Handling and Exception Messages
    • Also, see the Continued Improvements to Paul Welter's Templates

  • Atlanta .NET Regular Guys and Code Camp

    Matt Ranlett and Brendon Schwartz, aka the Atlanta .NET Regular Guys, met up with me recently for lunch and blogged about our chat in their "Tales from the Trenches" series.  I really enjoyed getting to learn more about both Matt and Brendon since I don't get out to the local user groups very often.  If you're in the Atlanta area then you really should have their blog in your reader since they are the definitive source for everything going on in Atlanta.  Their calendar has all the meetings in one place, often more accurate than the groups themselves, and they give attend all the meetings and summarize them.  They are also running the Atlanta Code Camp site, where I am going to be presenting "An Introduction to O/R Mapping" on May 14 at 8:45, using NHibernate in my examples due to the code camp "rules".   By the way, I'm always open to meeting anyone in the Atlanta area for lunch in Woodstock, Roswell/Alpharetta, or Marietta/Kennesaw -- its especially important when you work from home.