RTFM you idiot (me)

September 3, 2007 on 12:42 pm | In DotNet |
 

Have I told you lately that reading manuals is good thing? Wow, what a discovery! Believe me, reading the documentation, manuals, MSDN will save you time. One day spend on reading about .NET Framework fundamentals will save you 2 of debugging, and wandering why… I’ve recently found a nasty behavior in my search by example routine. I thought that I know enough about NHibernate to use find by example in discoverable mode (its when you are programming with Intelisense as your help and guide ;). My code looked like this:

  Customer exampleCustomer = new Customer();
  exampleCustomer.FirstName = view.FirstName;
  exampleCustomer.LastName = view.LastName;
  string[] excludeProps = new string[] { };
  CustomerList customerList =
    customerDao.GetByExample(
      exampleCustomer, excludeProps);

Nothing extraordinary. Right? the exampleCustomer object gets the FirstName and LastName property from view. Than without excluding any property I went to GetByExample to get what I wanted. It worked! Until the customer without FirstName (a company). What did I get when view.FirstName was = “”? A list of all customers with first name matching the attribute with last name ignored! Why? Because the NHibernate reference manual says:

rtfm

“By default, null valued properties and properties which return empty string from the call to ToString() are excluded”.

Right!

No Comments yet »

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds. Valid XHTML and CSS. ^Top^