Matrix Unload

  NullableTypes on SourceForge.net

NULLABLE TYPES FAQ _

NullableTypes vs. SqlTypes

Q: When and where to use NullableTypes and where to use System.Data.SqlTypes instead?

A: Use NullableTypes in the Business Layer: in the code that implements the application
   business logic (business entities, functions, services and business processes) and in
   public interfaces (nullable parameters, return type and properties). Use NullableTypes
   also in the Presentation Layer: in the code that implements the user interaction dialog
   (navigation, logic and presentation).
   Here NullableTypes do not just shift the problem of handling nulls with built-in
   value-types elsewhere, they do completely solve it in an elegant OO fashion that make
   code more readable and maintainable.
   In the Business Layer and in the Presentation Layer, NullableTypes are a valid general
   purpose solution: they are more reliable and efficient than every custom solution.

   Do prefer System.Data.SqlTypes (or the types provided by the .NET Data Provider in use,
   as the structures in System.Data.OracleClient or types in Oracle.DataAccess.Types) in
   the Data Layer: in the code that move data from the database (with a DataAdapter or
   with a DataCommand) to the memory (DataSet, variables, Array, etc.) and vice versa.
   This is because System.Data.SqlTypes (and types provided by other .NET Data Providers)
   are isomorphic with the database types while NullableTypes (as built-in types) are not.


Q: Why shouldn't I use System.Data.SqlTypes everywhere?

A: You can, but you can also do better with NullableTypes because System.Data.SqlTypes
   (and types provided by other .NET Data Providers) do:
   - not work with .NET Remoting
   - not work with ASP.NET Web Services
   - depends on SqlServer or other databases (it is not a good design to couple the
     Presentation Layer and the Business Layer with a specific database)
   While NullableTypes:
   - do work with .NET Remoting
   - do work with ASP.NET Web Services (in beta now)
   - are database agnostic
   - have the NullConvertClass that can be used to seamlessly integrate
     NullableTypes with Web Server controls and WinForms controls
   - have the DbNullConvert class that converts NullableTypes values to
     in-memory database values (Command Parameters, DataReader values, DataSet column
     values) and vice versa