view Source/Common/Convert.generated.cs @ 1:8f65451dc28f

Исправлена проблема с фабрикой и выборкой нескольких объектов в linq выражении
author cin
date Fri, 28 Mar 2014 01:04:56 +0400
parents f990fcb411a9
children
line wrap: on
line source

//---------------------------------------------------------------------------------------------------
// <auto-generated>
//    This code was generated by BLToolkit template for T4.
//    Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
// </auto-generated>
//---------------------------------------------------------------------------------------------------
using System;
using System.Data.Linq;
using System.Data.SqlTypes;
using System.Globalization;
using System.IO;
using System.Xml;
#if !SILVERLIGHT
using System.Xml.Linq;
#endif

namespace BLToolkit.Common
{
	using Properties;

	public partial class Convert
	{ 
		#region Simple Types

		#region Boolean

		// Simple Types
		//
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(Byte       p) { return p != 0;                                                                                                     }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(Decimal    p) { return p != 0;                                                                                                     }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(Double     p) { return p != 0;                                                                                                     }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(Int16      p) { return p != 0;                                                                                                     }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(Int32      p) { return p != 0;                                                                                                     }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(Int64      p) { return p != 0;                                                                                                     }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>Boolean</c> value.</summary>
		[CLSCompliant(false)]
		public static Boolean ToBoolean(SByte      p) { return p != 0;                                                                                                     }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(Single     p) { return p != 0;                                                                                                     }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(String     p) { return p == null? Configuration.NullableValues.Boolean : p.Length == 1 ? ToBoolean(p[0]) : Boolean.Parse(p);       }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>Boolean</c> value.</summary>
		[CLSCompliant(false)]
		public static Boolean ToBoolean(UInt16     p) { return p != 0;                                                                                                     }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>Boolean</c> value.</summary>
		[CLSCompliant(false)]
		public static Boolean ToBoolean(UInt32     p) { return p != 0;                                                                                                     }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>Boolean</c> value.</summary>
		[CLSCompliant(false)]
		public static Boolean ToBoolean(UInt64     p) { return p != 0;                                                                                                     }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(Boolean?   p) { return p.HasValue && p.Value;                                                                                      }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(Byte?      p) { return p.HasValue && p.Value != 0;                                                                                 }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(Char?      p) { return p.HasValue && ToBoolean(p.Value);                                                                           }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(Decimal?   p) { return p.HasValue && p.Value != 0;                                                                                 }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(Double?    p) { return p.HasValue && p.Value != 0;                                                                                 }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(Int16?     p) { return p.HasValue && p.Value != 0;                                                                                 }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(Int32?     p) { return p.HasValue && p.Value != 0;                                                                                 }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(Int64?     p) { return p.HasValue && p.Value != 0;                                                                                 }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>Boolean</c> value.</summary>
		[CLSCompliant(false)]
		public static Boolean ToBoolean(SByte?     p) { return p.HasValue && p.Value != 0;                                                                                 }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(Single?    p) { return p.HasValue && p.Value != 0;                                                                                 }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>Boolean</c> value.</summary>
		[CLSCompliant(false)]
		public static Boolean ToBoolean(UInt16?    p) { return p.HasValue && p.Value != 0;                                                                                 }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>Boolean</c> value.</summary>
		[CLSCompliant(false)]
		public static Boolean ToBoolean(UInt32?    p) { return p.HasValue && p.Value != 0;                                                                                 }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>Boolean</c> value.</summary>
		[CLSCompliant(false)]
		public static Boolean ToBoolean(UInt64?    p) { return p.HasValue && p.Value != 0;                                                                                 }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(Binary     p) { return p == null || p.Length == 0 ? Configuration.NullableValues.Boolean : BitConverter.ToBoolean(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(Byte[]     p) { return p == null || p.Length == 0 ? Configuration.NullableValues.Boolean : BitConverter.ToBoolean(p, 0);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(SqlBoolean p) { return !p.IsNull && p.Value;                                                                                       }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(SqlByte    p) { return !p.IsNull && ToBoolean(p.Value);                                                                            }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(SqlDecimal p) { return !p.IsNull && ToBoolean(p.Value);                                                                            }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(SqlDouble  p) { return !p.IsNull && ToBoolean(p.Value);                                                                            }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(SqlInt16   p) { return !p.IsNull && ToBoolean(p.Value);                                                                            }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(SqlInt32   p) { return !p.IsNull && ToBoolean(p.Value);                                                                            }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(SqlInt64   p) { return !p.IsNull && ToBoolean(p.Value);                                                                            }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(SqlMoney   p) { return !p.IsNull && ToBoolean(p.Value);                                                                            }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(SqlSingle  p) { return !p.IsNull && ToBoolean(p.Value);                                                                            }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(SqlString  p) { return !p.IsNull && ToBoolean(p.Value);                                                                            }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Boolean</c> value.</summary>
		public static Boolean ToBoolean(object p)
		{
			if (p == null) return Configuration.NullableValues.Boolean;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return Configuration.NullableValues.Boolean;
				case TypeCode.Boolean : return (Boolean)p;
				case TypeCode.Char    : return ToBoolean((Char)   p);
				case TypeCode.String  : return ToBoolean((String) p);
				case TypeCode.SByte   : return ToBoolean((SByte)  p);
				case TypeCode.Int16   : return ToBoolean((Int16)  p);
				case TypeCode.Int32   : return ToBoolean((Int32)  p);
				case TypeCode.Int64   : return ToBoolean((Int64)  p);
				case TypeCode.Byte    : return ToBoolean((Byte)   p);
				case TypeCode.UInt16  : return ToBoolean((UInt16) p);
				case TypeCode.UInt32  : return ToBoolean((UInt32) p);
				case TypeCode.UInt64  : return ToBoolean((UInt64) p);
				case TypeCode.Single  : return ToBoolean((Single) p);
				case TypeCode.Double  : return ToBoolean((Double) p);
				case TypeCode.Decimal : return ToBoolean((Decimal)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToBoolean((Boolean?)  p);
				if (p is Byte?)      return ToBoolean((Byte?)     p);
				if (p is Char?)      return ToBoolean((Char?)     p);
				if (p is Decimal?)   return ToBoolean((Decimal?)  p);
				if (p is Double?)    return ToBoolean((Double?)   p);
				if (p is Int16?)     return ToBoolean((Int16?)    p);
				if (p is Int32?)     return ToBoolean((Int32?)    p);
				if (p is Int64?)     return ToBoolean((Int64?)    p);
				if (p is SByte?)     return ToBoolean((SByte?)    p);
				if (p is Single?)    return ToBoolean((Single?)   p);
				if (p is UInt16?)    return ToBoolean((UInt16?)   p);
				if (p is UInt32?)    return ToBoolean((UInt32?)   p);
				if (p is UInt64?)    return ToBoolean((UInt64?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToBoolean((Binary)    p);
			if (p is Byte[])     return ToBoolean((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToBoolean((SqlBoolean)p);
				if (p is SqlByte)    return ToBoolean((SqlByte)   p);
				if (p is SqlDecimal) return ToBoolean((SqlDecimal)p);
				if (p is SqlDouble)  return ToBoolean((SqlDouble) p);
				if (p is SqlInt16)   return ToBoolean((SqlInt16)  p);
				if (p is SqlInt32)   return ToBoolean((SqlInt32)  p);
				if (p is SqlInt64)   return ToBoolean((SqlInt64)  p);
				if (p is SqlMoney)   return ToBoolean((SqlMoney)  p);
				if (p is SqlSingle)  return ToBoolean((SqlSingle) p);
				if (p is SqlString)  return ToBoolean((SqlString) p);
			}

#endif

			if (p is IConvertible) return ((IConvertible)p).ToBoolean(null);

			throw CreateInvalidCastException(p.GetType(), typeof(Boolean));
		}

		#endregion

		#region Byte

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(Boolean    p) { return p ? (Byte)1 : (Byte)0;                                                           }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(Char       p) { return checked((Byte)p);                                                                }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(Decimal    p) { return checked((Byte)p);                                                                }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(Double     p) { return checked((Byte)p);                                                                }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(Int16      p) { return checked((Byte)p);                                                                }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(Int32      p) { return checked((Byte)p);                                                                }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(Int64      p) { return checked((Byte)p);                                                                }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>Byte</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte ToByte(SByte      p) { return checked((Byte)p);                                                                }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(Single     p) { return checked((Byte)p);                                                                }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(String     p) { return p == null? Configuration.NullableValues.Byte : Byte.Parse(p);                    }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>Byte</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte ToByte(UInt16     p) { return checked((Byte)p);                                                                }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>Byte</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte ToByte(UInt32     p) { return checked((Byte)p);                                                                }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>Byte</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte ToByte(UInt64     p) { return checked((Byte)p);                                                                }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(Boolean?   p) { return p.HasValue && p.Value ? (Byte)1: (Byte)0;                                        }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(Byte?      p) { return p.HasValue ? p.Value : Configuration.NullableValues.Byte;                        }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(Char?      p) { return p.HasValue ? checked((Byte)p.Value) : Configuration.NullableValues.Byte;         }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(Decimal?   p) { return p.HasValue ? checked((Byte)p.Value) : Configuration.NullableValues.Byte;         }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(Double?    p) { return p.HasValue ? checked((Byte)p.Value) : Configuration.NullableValues.Byte;         }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(Int16?     p) { return p.HasValue ? checked((Byte)p.Value) : Configuration.NullableValues.Byte;         }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(Int32?     p) { return p.HasValue ? checked((Byte)p.Value) : Configuration.NullableValues.Byte;         }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(Int64?     p) { return p.HasValue ? checked((Byte)p.Value) : Configuration.NullableValues.Byte;         }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>Byte</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte ToByte(SByte?     p) { return p.HasValue ? checked((Byte)p.Value) : Configuration.NullableValues.Byte;         }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(Single?    p) { return p.HasValue ? checked((Byte)p.Value) : Configuration.NullableValues.Byte;         }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>Byte</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte ToByte(UInt16?    p) { return p.HasValue ? checked((Byte)p.Value) : Configuration.NullableValues.Byte;         }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>Byte</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte ToByte(UInt32?    p) { return p.HasValue ? checked((Byte)p.Value) : Configuration.NullableValues.Byte;         }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>Byte</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte ToByte(UInt64?    p) { return p.HasValue ? checked((Byte)p.Value) : Configuration.NullableValues.Byte;         }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(Binary     p) { return p == null || p.Length == 0 ? Configuration.NullableValues.Byte : p.ToArray()[0]; }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(Byte[]     p) { return p == null || p.Length == 0 ? Configuration.NullableValues.Byte : p[0];           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(SqlBoolean p) { return p.IsNull ? Configuration.NullableValues.Byte : ToByte(p.Value);                  }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(SqlByte    p) { return p.IsNull ? Configuration.NullableValues.Byte : p.Value;                          }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(SqlDecimal p) { return p.IsNull ? Configuration.NullableValues.Byte : ToByte(p.Value);                  }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(SqlDouble  p) { return p.IsNull ? Configuration.NullableValues.Byte : ToByte(p.Value);                  }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(SqlInt16   p) { return p.IsNull ? Configuration.NullableValues.Byte : ToByte(p.Value);                  }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(SqlInt32   p) { return p.IsNull ? Configuration.NullableValues.Byte : ToByte(p.Value);                  }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(SqlInt64   p) { return p.IsNull ? Configuration.NullableValues.Byte : ToByte(p.Value);                  }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(SqlMoney   p) { return p.IsNull ? Configuration.NullableValues.Byte : ToByte(p.Value);                  }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(SqlSingle  p) { return p.IsNull ? Configuration.NullableValues.Byte : ToByte(p.Value);                  }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(SqlString  p) { return p.IsNull ? Configuration.NullableValues.Byte : ToByte(p.Value);                  }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Byte</c> value.</summary>
		public static Byte ToByte(object p)
		{
			if (p == null) return Configuration.NullableValues.Byte;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return Configuration.NullableValues.Byte;
				case TypeCode.Byte    : return (Byte)p;
				case TypeCode.SByte   : return ToByte((SByte)  p);
				case TypeCode.Int16   : return ToByte((Int16)  p);
				case TypeCode.Int32   : return ToByte((Int32)  p);
				case TypeCode.Int64   : return ToByte((Int64)  p);
				case TypeCode.UInt16  : return ToByte((UInt16) p);
				case TypeCode.UInt32  : return ToByte((UInt32) p);
				case TypeCode.UInt64  : return ToByte((UInt64) p);
				case TypeCode.Single  : return ToByte((Single) p);
				case TypeCode.Double  : return ToByte((Double) p);
				case TypeCode.Decimal : return ToByte((Decimal)p);
				case TypeCode.Char    : return ToByte((Char)   p);
				case TypeCode.String  : return ToByte((String) p);
				case TypeCode.Boolean : return ToByte((Boolean)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToByte((Boolean?)  p);
				if (p is Byte?)      return ToByte((Byte?)     p);
				if (p is Char?)      return ToByte((Char?)     p);
				if (p is Decimal?)   return ToByte((Decimal?)  p);
				if (p is Double?)    return ToByte((Double?)   p);
				if (p is Int16?)     return ToByte((Int16?)    p);
				if (p is Int32?)     return ToByte((Int32?)    p);
				if (p is Int64?)     return ToByte((Int64?)    p);
				if (p is SByte?)     return ToByte((SByte?)    p);
				if (p is Single?)    return ToByte((Single?)   p);
				if (p is UInt16?)    return ToByte((UInt16?)   p);
				if (p is UInt32?)    return ToByte((UInt32?)   p);
				if (p is UInt64?)    return ToByte((UInt64?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToByte((Binary)    p);
			if (p is Byte[])     return ToByte((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToByte((SqlBoolean)p);
				if (p is SqlByte)    return ToByte((SqlByte)   p);
				if (p is SqlDecimal) return ToByte((SqlDecimal)p);
				if (p is SqlDouble)  return ToByte((SqlDouble) p);
				if (p is SqlInt16)   return ToByte((SqlInt16)  p);
				if (p is SqlInt32)   return ToByte((SqlInt32)  p);
				if (p is SqlInt64)   return ToByte((SqlInt64)  p);
				if (p is SqlMoney)   return ToByte((SqlMoney)  p);
				if (p is SqlSingle)  return ToByte((SqlSingle) p);
				if (p is SqlString)  return ToByte((SqlString) p);
			}

#endif

			if (p is IConvertible) return ((IConvertible)p).ToByte(null);

			throw CreateInvalidCastException(p.GetType(), typeof(Byte));
		}

		#endregion

		#region Char

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(Boolean    p) { return p ? (Char)1 : (Char)0;                                                                                }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(Byte       p) { return checked((Char)p);                                                                                     }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(Decimal    p) { return checked((Char)p);                                                                                     }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(Double     p) { return checked((Char)p);                                                                                     }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(Int16      p) { return checked((Char)p);                                                                                     }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(Int32      p) { return checked((Char)p);                                                                                     }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(Int64      p) { return checked((Char)p);                                                                                     }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>Char</c> value.</summary>
		[CLSCompliant(false)]
		public static Char ToChar(SByte      p) { return checked((Char)p);                                                                                     }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(Single     p) { return checked((Char)p);                                                                                     }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(String     p) { return string.IsNullOrEmpty(p)? (Char)0 : p[0];                                                              }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>Char</c> value.</summary>
		[CLSCompliant(false)]
		public static Char ToChar(UInt16     p) { return checked((Char)p);                                                                                     }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>Char</c> value.</summary>
		[CLSCompliant(false)]
		public static Char ToChar(UInt32     p) { return checked((Char)p);                                                                                     }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>Char</c> value.</summary>
		[CLSCompliant(false)]
		public static Char ToChar(UInt64     p) { return checked((Char)p);                                                                                     }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(Boolean?   p) { return p.HasValue && p.Value ? (Char)1: (Char)0;                                                             }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(Byte?      p) { return p.HasValue ? checked((Char)p.Value) : Configuration.NullableValues.Char;                              }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(Char?      p) { return p.HasValue ? p.Value : Configuration.NullableValues.Char;                                             }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(Decimal?   p) { return p.HasValue ? checked((Char)p.Value) : Configuration.NullableValues.Char;                              }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(Double?    p) { return p.HasValue ? checked((Char)p.Value) : Configuration.NullableValues.Char;                              }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(Int16?     p) { return p.HasValue ? checked((Char)p.Value) : Configuration.NullableValues.Char;                              }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(Int32?     p) { return p.HasValue ? checked((Char)p.Value) : Configuration.NullableValues.Char;                              }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(Int64?     p) { return p.HasValue ? checked((Char)p.Value) : Configuration.NullableValues.Char;                              }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>Char</c> value.</summary>
		[CLSCompliant(false)]
		public static Char ToChar(SByte?     p) { return p.HasValue ? checked((Char)p.Value) : Configuration.NullableValues.Char;                              }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(Single?    p) { return p.HasValue ? checked((Char)p.Value) : Configuration.NullableValues.Char;                              }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>Char</c> value.</summary>
		[CLSCompliant(false)]
		public static Char ToChar(UInt16?    p) { return p.HasValue ? checked((Char)p.Value) : Configuration.NullableValues.Char;                              }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>Char</c> value.</summary>
		[CLSCompliant(false)]
		public static Char ToChar(UInt32?    p) { return p.HasValue ? checked((Char)p.Value) : Configuration.NullableValues.Char;                              }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>Char</c> value.</summary>
		[CLSCompliant(false)]
		public static Char ToChar(UInt64?    p) { return p.HasValue ? checked((Char)p.Value) : Configuration.NullableValues.Char;                              }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(Binary     p) { return p == null || p.Length == 0 ? Configuration.NullableValues.Char : BitConverter.ToChar(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(Byte[]     p) { return p == null || p.Length == 0 ? Configuration.NullableValues.Char : BitConverter.ToChar(p, 0);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(SqlBoolean p) { return p.IsNull ? Configuration.NullableValues.Char : ToChar(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(SqlByte    p) { return p.IsNull ? Configuration.NullableValues.Char : ToChar(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(SqlDecimal p) { return p.IsNull ? Configuration.NullableValues.Char : ToChar(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(SqlDouble  p) { return p.IsNull ? Configuration.NullableValues.Char : ToChar(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(SqlInt16   p) { return p.IsNull ? Configuration.NullableValues.Char : ToChar(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(SqlInt32   p) { return p.IsNull ? Configuration.NullableValues.Char : ToChar(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(SqlInt64   p) { return p.IsNull ? Configuration.NullableValues.Char : ToChar(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(SqlMoney   p) { return p.IsNull ? Configuration.NullableValues.Char : ToChar(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(SqlSingle  p) { return p.IsNull ? Configuration.NullableValues.Char : ToChar(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(SqlString  p) { return p.IsNull ? Configuration.NullableValues.Char : ToChar(p.Value);                                       }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Char</c> value.</summary>
		public static Char ToChar(object p)
		{
			if (p == null) return Configuration.NullableValues.Char;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return Configuration.NullableValues.Char;
				case TypeCode.Char    : return (Char)p;
				case TypeCode.SByte   : return ToChar((SByte)  p);
				case TypeCode.Int16   : return ToChar((Int16)  p);
				case TypeCode.Int32   : return ToChar((Int32)  p);
				case TypeCode.Int64   : return ToChar((Int64)  p);
				case TypeCode.Byte    : return ToChar((Byte)   p);
				case TypeCode.UInt16  : return ToChar((UInt16) p);
				case TypeCode.UInt32  : return ToChar((UInt32) p);
				case TypeCode.UInt64  : return ToChar((UInt64) p);
				case TypeCode.Single  : return ToChar((Single) p);
				case TypeCode.Double  : return ToChar((Double) p);
				case TypeCode.Decimal : return ToChar((Decimal)p);
				case TypeCode.String  : return ToChar((String) p);
				case TypeCode.Boolean : return ToChar((Boolean)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToChar((Boolean?)  p);
				if (p is Byte?)      return ToChar((Byte?)     p);
				if (p is Char?)      return ToChar((Char?)     p);
				if (p is Decimal?)   return ToChar((Decimal?)  p);
				if (p is Double?)    return ToChar((Double?)   p);
				if (p is Int16?)     return ToChar((Int16?)    p);
				if (p is Int32?)     return ToChar((Int32?)    p);
				if (p is Int64?)     return ToChar((Int64?)    p);
				if (p is SByte?)     return ToChar((SByte?)    p);
				if (p is Single?)    return ToChar((Single?)   p);
				if (p is UInt16?)    return ToChar((UInt16?)   p);
				if (p is UInt32?)    return ToChar((UInt32?)   p);
				if (p is UInt64?)    return ToChar((UInt64?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToChar((Binary)    p);
			if (p is Byte[])     return ToChar((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToChar((SqlBoolean)p);
				if (p is SqlByte)    return ToChar((SqlByte)   p);
				if (p is SqlDecimal) return ToChar((SqlDecimal)p);
				if (p is SqlDouble)  return ToChar((SqlDouble) p);
				if (p is SqlInt16)   return ToChar((SqlInt16)  p);
				if (p is SqlInt32)   return ToChar((SqlInt32)  p);
				if (p is SqlInt64)   return ToChar((SqlInt64)  p);
				if (p is SqlMoney)   return ToChar((SqlMoney)  p);
				if (p is SqlSingle)  return ToChar((SqlSingle) p);
				if (p is SqlString)  return ToChar((SqlString) p);
			}

#endif

			if (p is IConvertible) return ((IConvertible)p).ToChar(null);

			throw CreateInvalidCastException(p.GetType(), typeof(Char));
		}

		#endregion

		#region DateTime

		// Simple Types
		//
		/// <summary>Converts the value from <c>DateTimeOffset</c> to an equivalent <c>DateTime</c> value.</summary>
		public static DateTime ToDateTime(DateTimeOffset  p) { return p.LocalDateTime;                                                                                                  }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>DateTime</c> value.</summary>
		public static DateTime ToDateTime(Double          p) { return DateTime.MinValue + TimeSpan.FromDays (p);                                                                        }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>DateTime</c> value.</summary>
		public static DateTime ToDateTime(Int64           p) { return DateTime.MinValue + TimeSpan.FromTicks(p);                                                                        }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>DateTime</c> value.</summary>
		public static DateTime ToDateTime(String          p) { return p == null ? Configuration.NullableValues.DateTime : DateTime.Parse(p, null, DateTimeStyles.NoCurrentDateDefault); }
		/// <summary>Converts the value from <c>TimeSpan</c> to an equivalent <c>DateTime</c> value.</summary>
		public static DateTime ToDateTime(TimeSpan        p) { return DateTime.MinValue + p;                                                                                            }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>DateTime?</c> to an equivalent <c>DateTime</c> value.</summary>
		public static DateTime ToDateTime(DateTime?       p) { return p.HasValue ? p.Value : Configuration.NullableValues.DateTime;                                                     }
		/// <summary>Converts the value from <c>DateTimeOffset?</c> to an equivalent <c>DateTime</c> value.</summary>
		public static DateTime ToDateTime(DateTimeOffset? p) { return p.HasValue ?                     p.Value.LocalDateTime : Configuration.NullableValues.DateTime;                   }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>DateTime</c> value.</summary>
		public static DateTime ToDateTime(Double?         p) { return p.HasValue ? DateTime.MinValue + TimeSpan.FromDays (p.Value): Configuration.NullableValues.DateTime;              }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>DateTime</c> value.</summary>
		public static DateTime ToDateTime(Int64?          p) { return p.HasValue ? DateTime.MinValue + TimeSpan.FromTicks(p.Value): Configuration.NullableValues.DateTime;              }
		/// <summary>Converts the value from <c>TimeSpan?</c> to an equivalent <c>DateTime</c> value.</summary>
		public static DateTime ToDateTime(TimeSpan?       p) { return p.HasValue ? DateTime.MinValue +                    p.Value : Configuration.NullableValues.DateTime;              }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>DateTime</c> value.</summary>
		public static DateTime ToDateTime(Binary          p) { return p == null || p.Length == 0 ? Configuration.NullableValues.DateTime : DateTime.FromBinary(ToInt64(p.ToArray()));   }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>DateTime</c> value.</summary>
		public static DateTime ToDateTime(Byte[]          p) { return p == null || p.Length == 0 ? Configuration.NullableValues.DateTime : DateTime.FromBinary(ToInt64(p));             }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlDateTime</c> to an equivalent <c>DateTime</c> value.</summary>
		public static DateTime ToDateTime(SqlDateTime     p) { return p.IsNull ? Configuration.NullableValues.DateTime : p.Value;                                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>DateTime</c> value.</summary>
		public static DateTime ToDateTime(SqlDouble       p) { return p.IsNull   ? Configuration.NullableValues.DateTime : DateTime.MinValue + TimeSpan.FromDays (p.Value);             }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>DateTime</c> value.</summary>
		public static DateTime ToDateTime(SqlInt64        p) { return p.IsNull   ? Configuration.NullableValues.DateTime : DateTime.MinValue + TimeSpan.FromTicks(p.Value);             }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>DateTime</c> value.</summary>
		public static DateTime ToDateTime(SqlString       p) { return p.IsNull   ? Configuration.NullableValues.DateTime :                             ToDateTime(p.Value);             }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>DateTime</c> value.</summary>
		public static DateTime ToDateTime(object p)
		{
			if (p == null) return Configuration.NullableValues.DateTime;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull   : return Configuration.NullableValues.DateTime;
				case TypeCode.DateTime : return (DateTime)p;
				case TypeCode.String   : return ToDateTime((String)  p);
				case TypeCode.Int64    : return ToDateTime((Int64)   p);
				case TypeCode.Double   : return ToDateTime((Double)  p);
			}

			// Simple Types
			//
			if (p is DateTimeOffset)  return ToDateTime((DateTimeOffset) p);
			if (p is TimeSpan)        return ToDateTime((TimeSpan)       p);

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is DateTime?)       return ToDateTime((DateTime?)      p);
				if (p is DateTimeOffset?) return ToDateTime((DateTimeOffset?)p);
				if (p is Double?)         return ToDateTime((Double?)        p);
				if (p is Int64?)          return ToDateTime((Int64?)         p);
				if (p is TimeSpan?)       return ToDateTime((TimeSpan?)      p);
			}

			// Other Types
			//
			if (p is Binary)          return ToDateTime((Binary)         p);
			if (p is Byte[])          return ToDateTime((Byte[])         p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlDateTime)     return ToDateTime((SqlDateTime)    p);
				if (p is SqlDouble)       return ToDateTime((SqlDouble)      p);
				if (p is SqlInt64)        return ToDateTime((SqlInt64)       p);
				if (p is SqlString)       return ToDateTime((SqlString)      p);
			}

#endif

			if (p is IConvertible) return ((IConvertible)p).ToDateTime(null);

			throw CreateInvalidCastException(p.GetType(), typeof(DateTime));
		}

		#endregion

		#region DateTimeOffset

		// Simple Types
		//
		/// <summary>Converts the value from <c>DateTime</c> to an equivalent <c>DateTimeOffset</c> value.</summary>
		public static DateTimeOffset ToDateTimeOffset(DateTime        p) { return p;                                                                                                  }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>DateTimeOffset</c> value.</summary>
		public static DateTimeOffset ToDateTimeOffset(Double          p) { return DateTimeOffset.MinValue + TimeSpan.FromDays (p);                                                    }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>DateTimeOffset</c> value.</summary>
		public static DateTimeOffset ToDateTimeOffset(Int64           p) { return DateTimeOffset.MinValue + TimeSpan.FromTicks(p);                                                    }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>DateTimeOffset</c> value.</summary>
		public static DateTimeOffset ToDateTimeOffset(String          p) { return p == null? DateTimeOffset.MinValue : DateTimeOffset.Parse(p);                                       }
		/// <summary>Converts the value from <c>TimeSpan</c> to an equivalent <c>DateTimeOffset</c> value.</summary>
		public static DateTimeOffset ToDateTimeOffset(TimeSpan        p) { return DateTimeOffset.MinValue + p;                                                                        }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>DateTime?</c> to an equivalent <c>DateTimeOffset</c> value.</summary>
		public static DateTimeOffset ToDateTimeOffset(DateTime?       p) { return p.HasValue ?                                   p.Value : DateTimeOffset.MinValue;                   }
		/// <summary>Converts the value from <c>DateTimeOffset?</c> to an equivalent <c>DateTimeOffset</c> value.</summary>
		public static DateTimeOffset ToDateTimeOffset(DateTimeOffset? p) { return p.HasValue ? p.Value : DateTimeOffset.MinValue;                                                     }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>DateTimeOffset</c> value.</summary>
		public static DateTimeOffset ToDateTimeOffset(Double?         p) { return p.HasValue ? DateTimeOffset.MinValue + TimeSpan.FromDays (p.Value): DateTimeOffset.MinValue;        }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>DateTimeOffset</c> value.</summary>
		public static DateTimeOffset ToDateTimeOffset(Int64?          p) { return p.HasValue ? DateTimeOffset.MinValue + TimeSpan.FromTicks(p.Value): DateTimeOffset.MinValue;        }
		/// <summary>Converts the value from <c>TimeSpan?</c> to an equivalent <c>DateTimeOffset</c> value.</summary>
		public static DateTimeOffset ToDateTimeOffset(TimeSpan?       p) { return p.HasValue ? DateTimeOffset.MinValue +                    p.Value : DateTimeOffset.MinValue;        }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>DateTimeOffset</c> value.</summary>
		public static DateTimeOffset ToDateTimeOffset(Binary          p) { return p == null || p.Length == 0 ? DateTimeOffset.MinValue : new DateTimeOffset(ToDateTime(p.ToArray())); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>DateTimeOffset</c> value.</summary>
		public static DateTimeOffset ToDateTimeOffset(Byte[]          p) { return p == null || p.Length == 0 ? DateTimeOffset.MinValue : new DateTimeOffset(ToDateTime(p));           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlDateTime</c> to an equivalent <c>DateTimeOffset</c> value.</summary>
		public static DateTimeOffset ToDateTimeOffset(SqlDateTime     p) { return p.IsNull   ? DateTimeOffset.MinValue :                                   p.Value;                   }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>DateTimeOffset</c> value.</summary>
		public static DateTimeOffset ToDateTimeOffset(SqlDouble       p) { return p.IsNull   ? DateTimeOffset.MinValue : DateTimeOffset.MinValue + TimeSpan.FromDays (p.Value);       }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>DateTimeOffset</c> value.</summary>
		public static DateTimeOffset ToDateTimeOffset(SqlInt64        p) { return p.IsNull   ? DateTimeOffset.MinValue : DateTimeOffset.MinValue + TimeSpan.FromTicks(p.Value);       }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>DateTimeOffset</c> value.</summary>
		public static DateTimeOffset ToDateTimeOffset(SqlString       p) { return p.IsNull   ? DateTimeOffset.MinValue :                  ToDateTimeOffset(p.Value);                  }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>DateTimeOffset</c> value.</summary>
		public static DateTimeOffset ToDateTimeOffset(object p)
		{
			if (p == null) return DateTimeOffset.MinValue;

			if (p is DateTimeOffset) return (DateTimeOffset)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull         : return DateTimeOffset.MinValue;
				case TypeCode.Int64          : return ToDateTimeOffset((Int64)         p);
				case TypeCode.Double         : return ToDateTimeOffset((Double)        p);
				case TypeCode.DateTime       : return ToDateTimeOffset((DateTime)      p);
				case TypeCode.String         : return ToDateTimeOffset((String)        p);
			}

			// Simple Types
			//
			if (p is TimeSpan)        return ToDateTimeOffset((TimeSpan)       p);

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is DateTime?)       return ToDateTimeOffset((DateTime?)      p);
				if (p is DateTimeOffset?) return ToDateTimeOffset((DateTimeOffset?)p);
				if (p is Double?)         return ToDateTimeOffset((Double?)        p);
				if (p is Int64?)          return ToDateTimeOffset((Int64?)         p);
				if (p is TimeSpan?)       return ToDateTimeOffset((TimeSpan?)      p);
			}

			// Other Types
			//
			if (p is Binary)          return ToDateTimeOffset((Binary)         p);
			if (p is Byte[])          return ToDateTimeOffset((Byte[])         p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlDateTime)     return ToDateTimeOffset((SqlDateTime)    p);
				if (p is SqlDouble)       return ToDateTimeOffset((SqlDouble)      p);
				if (p is SqlInt64)        return ToDateTimeOffset((SqlInt64)       p);
				if (p is SqlString)       return ToDateTimeOffset((SqlString)      p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(DateTimeOffset));
		}

		#endregion

		#region Decimal

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(Boolean    p) { return p ? (Decimal)1 : (Decimal)0;                                                   }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(Byte       p) { return p;                                                                             }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(Char       p) { return p;                                                                             }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(Double     p) { return checked((Decimal)p);                                                           }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(Int16      p) { return p;                                                                             }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(Int32      p) { return p;                                                                             }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(Int64      p) { return p;                                                                             }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>Decimal</c> value.</summary>
		[CLSCompliant(false)]
		public static Decimal ToDecimal(SByte      p) { return p;                                                                             }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(Single     p) { return checked((Decimal)p);                                                           }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(String     p) { return p == null? Configuration.NullableValues.Decimal : Decimal.Parse(p);            }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>Decimal</c> value.</summary>
		[CLSCompliant(false)]
		public static Decimal ToDecimal(UInt16     p) { return p;                                                                             }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>Decimal</c> value.</summary>
		[CLSCompliant(false)]
		public static Decimal ToDecimal(UInt32     p) { return p;                                                                             }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>Decimal</c> value.</summary>
		[CLSCompliant(false)]
		public static Decimal ToDecimal(UInt64     p) { return p;                                                                             }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(Boolean?   p) { return p.HasValue && p.Value ? (Decimal)1: (Decimal)0;                                }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(Byte?      p) { return p.HasValue ? p.Value : Configuration.NullableValues.Decimal;                   }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(Char?      p) { return p.HasValue ? p.Value : Configuration.NullableValues.Decimal;                   }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(Decimal?   p) { return p.HasValue ? p.Value : Configuration.NullableValues.Decimal;                   }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(Double?    p) { return p.HasValue ? checked((Decimal)p.Value) : Configuration.NullableValues.Decimal; }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(Int16?     p) { return p.HasValue ? p.Value : Configuration.NullableValues.Decimal;                   }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(Int32?     p) { return p.HasValue ? p.Value : Configuration.NullableValues.Decimal;                   }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(Int64?     p) { return p.HasValue ? p.Value : Configuration.NullableValues.Decimal;                   }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>Decimal</c> value.</summary>
		[CLSCompliant(false)]
		public static Decimal ToDecimal(SByte?     p) { return p.HasValue ? p.Value : Configuration.NullableValues.Decimal;                   }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(Single?    p) { return p.HasValue ? checked((Decimal)p.Value) : Configuration.NullableValues.Decimal; }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>Decimal</c> value.</summary>
		[CLSCompliant(false)]
		public static Decimal ToDecimal(UInt16?    p) { return p.HasValue ? p.Value : Configuration.NullableValues.Decimal;                   }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>Decimal</c> value.</summary>
		[CLSCompliant(false)]
		public static Decimal ToDecimal(UInt32?    p) { return p.HasValue ? p.Value : Configuration.NullableValues.Decimal;                   }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>Decimal</c> value.</summary>
		[CLSCompliant(false)]
		public static Decimal ToDecimal(UInt64?    p) { return p.HasValue ? p.Value : Configuration.NullableValues.Decimal;                   }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(SqlBoolean p) { return p.IsNull ? Configuration.NullableValues.Decimal : ToDecimal(p.Value);          }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(SqlByte    p) { return p.IsNull ? Configuration.NullableValues.Decimal : p.Value;                     }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(SqlDecimal p) { return p.IsNull ? Configuration.NullableValues.Decimal : p.Value;                     }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(SqlDouble  p) { return p.IsNull ? Configuration.NullableValues.Decimal : ToDecimal(p.Value);          }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(SqlInt16   p) { return p.IsNull ? Configuration.NullableValues.Decimal : p.Value;                     }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(SqlInt32   p) { return p.IsNull ? Configuration.NullableValues.Decimal : p.Value;                     }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(SqlInt64   p) { return p.IsNull ? Configuration.NullableValues.Decimal : p.Value;                     }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(SqlMoney   p) { return p.IsNull ? Configuration.NullableValues.Decimal : p.Value;                     }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(SqlSingle  p) { return p.IsNull ? Configuration.NullableValues.Decimal : ToDecimal(p.Value);          }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(SqlString  p) { return p.IsNull ? Configuration.NullableValues.Decimal : ToDecimal(p.Value);          }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Decimal</c> value.</summary>
		public static Decimal ToDecimal(object p)
		{
			if (p == null) return Configuration.NullableValues.Decimal;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return Configuration.NullableValues.Decimal;
				case TypeCode.Decimal : return (Decimal)p;
				case TypeCode.SByte   : return ToDecimal((SByte)  p);
				case TypeCode.Int16   : return ToDecimal((Int16)  p);
				case TypeCode.Int32   : return ToDecimal((Int32)  p);
				case TypeCode.Int64   : return ToDecimal((Int64)  p);
				case TypeCode.Byte    : return ToDecimal((Byte)   p);
				case TypeCode.UInt16  : return ToDecimal((UInt16) p);
				case TypeCode.UInt32  : return ToDecimal((UInt32) p);
				case TypeCode.Char    : return ToDecimal((Char)   p);
				case TypeCode.UInt64  : return ToDecimal((UInt64) p);
				case TypeCode.Single  : return ToDecimal((Single) p);
				case TypeCode.Double  : return ToDecimal((Double) p);
				case TypeCode.String  : return ToDecimal((String) p);
				case TypeCode.Boolean : return ToDecimal((Boolean)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToDecimal((Boolean?)  p);
				if (p is Byte?)      return ToDecimal((Byte?)     p);
				if (p is Char?)      return ToDecimal((Char?)     p);
				if (p is Decimal?)   return ToDecimal((Decimal?)  p);
				if (p is Double?)    return ToDecimal((Double?)   p);
				if (p is Int16?)     return ToDecimal((Int16?)    p);
				if (p is Int32?)     return ToDecimal((Int32?)    p);
				if (p is Int64?)     return ToDecimal((Int64?)    p);
				if (p is SByte?)     return ToDecimal((SByte?)    p);
				if (p is Single?)    return ToDecimal((Single?)   p);
				if (p is UInt16?)    return ToDecimal((UInt16?)   p);
				if (p is UInt32?)    return ToDecimal((UInt32?)   p);
				if (p is UInt64?)    return ToDecimal((UInt64?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToDecimal((Binary)    p);
			if (p is Byte[])     return ToDecimal((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToDecimal((SqlBoolean)p);
				if (p is SqlByte)    return ToDecimal((SqlByte)   p);
				if (p is SqlDecimal) return ToDecimal((SqlDecimal)p);
				if (p is SqlDouble)  return ToDecimal((SqlDouble) p);
				if (p is SqlInt16)   return ToDecimal((SqlInt16)  p);
				if (p is SqlInt32)   return ToDecimal((SqlInt32)  p);
				if (p is SqlInt64)   return ToDecimal((SqlInt64)  p);
				if (p is SqlMoney)   return ToDecimal((SqlMoney)  p);
				if (p is SqlSingle)  return ToDecimal((SqlSingle) p);
				if (p is SqlString)  return ToDecimal((SqlString) p);
			}

#endif

			if (p is IConvertible) return ((IConvertible)p).ToDecimal(null);

			throw CreateInvalidCastException(p.GetType(), typeof(Decimal));
		}

		#endregion

		#region Double

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(Boolean         p) { return p ? (Double)1 : (Double)0;                                                                                }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(Byte            p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(Char            p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>DateTime</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(DateTime        p) { return (p - DateTime.MinValue).TotalDays;                                                                        }
		/// <summary>Converts the value from <c>DateTimeOffset</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(DateTimeOffset  p) { return (p - DateTimeOffset.MinValue).TotalDays;                                                                  }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(Decimal         p) { return checked((Double)p);                                                                                       }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(Int16           p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(Int32           p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(Int64           p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>Double</c> value.</summary>
		[CLSCompliant(false)]
		public static Double ToDouble(SByte           p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(Single          p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(String          p) { return p == null? Configuration.NullableValues.Double : Double.Parse(p);                                         }
		/// <summary>Converts the value from <c>TimeSpan</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(TimeSpan        p) { return p.TotalDays;                                                                                              }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>Double</c> value.</summary>
		[CLSCompliant(false)]
		public static Double ToDouble(UInt16          p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>Double</c> value.</summary>
		[CLSCompliant(false)]
		public static Double ToDouble(UInt32          p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>Double</c> value.</summary>
		[CLSCompliant(false)]
		public static Double ToDouble(UInt64          p) { return p;                                                                                                        }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(Boolean?        p) { return p.HasValue && p.Value ? (Double)1: (Double)0;                                                             }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(Byte?           p) { return p.HasValue ? p.Value : Configuration.NullableValues.Double;                                               }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(Char?           p) { return p.HasValue ? p.Value : Configuration.NullableValues.Double;                                               }
		/// <summary>Converts the value from <c>DateTime?</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(DateTime?       p) { return p.HasValue ? (p.Value - DateTime.MinValue).TotalDays : Configuration.NullableValues.Double;               }
		/// <summary>Converts the value from <c>DateTimeOffset?</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(DateTimeOffset? p) { return p.HasValue ? (p.Value - DateTimeOffset.MinValue).TotalDays : Configuration.NullableValues.Double;         }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(Decimal?        p) { return p.HasValue ? checked((Double)p.Value) : Configuration.NullableValues.Double;                              }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(Double?         p) { return p.HasValue ? p.Value : Configuration.NullableValues.Double;                                               }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(Int16?          p) { return p.HasValue ? p.Value : Configuration.NullableValues.Double;                                               }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(Int32?          p) { return p.HasValue ? p.Value : Configuration.NullableValues.Double;                                               }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(Int64?          p) { return p.HasValue ? p.Value : Configuration.NullableValues.Double;                                               }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>Double</c> value.</summary>
		[CLSCompliant(false)]
		public static Double ToDouble(SByte?          p) { return p.HasValue ? p.Value : Configuration.NullableValues.Double;                                               }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(Single?         p) { return p.HasValue ? p.Value : Configuration.NullableValues.Double;                                               }
		/// <summary>Converts the value from <c>TimeSpan?</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(TimeSpan?       p) { return p.HasValue ? p.Value.TotalDays : Configuration.NullableValues.Double;                                     }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>Double</c> value.</summary>
		[CLSCompliant(false)]
		public static Double ToDouble(UInt16?         p) { return p.HasValue ? p.Value : Configuration.NullableValues.Double;                                               }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>Double</c> value.</summary>
		[CLSCompliant(false)]
		public static Double ToDouble(UInt32?         p) { return p.HasValue ? p.Value : Configuration.NullableValues.Double;                                               }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>Double</c> value.</summary>
		[CLSCompliant(false)]
		public static Double ToDouble(UInt64?         p) { return p.HasValue ? p.Value : Configuration.NullableValues.Double;                                               }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(Binary          p) { return p == null || p.Length == 0 ? Configuration.NullableValues.Double : BitConverter.ToDouble(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(Byte[]          p) { return p == null || p.Length == 0 ? Configuration.NullableValues.Double : BitConverter.ToDouble(p, 0);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(SqlBoolean      p) { return p.IsNull ? Configuration.NullableValues.Double : ToDouble(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(SqlByte         p) { return p.IsNull ? Configuration.NullableValues.Double : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlDateTime</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(SqlDateTime     p) { return p.IsNull ? Configuration.NullableValues.Double : ToDouble(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(SqlDecimal      p) { return p.IsNull ? Configuration.NullableValues.Double : ToDouble(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(SqlDouble       p) { return p.IsNull ? Configuration.NullableValues.Double : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(SqlInt16        p) { return p.IsNull ? Configuration.NullableValues.Double : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(SqlInt32        p) { return p.IsNull ? Configuration.NullableValues.Double : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(SqlInt64        p) { return p.IsNull ? Configuration.NullableValues.Double : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(SqlMoney        p) { return p.IsNull ? Configuration.NullableValues.Double : ToDouble(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(SqlSingle       p) { return p.IsNull ? Configuration.NullableValues.Double : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(SqlString       p) { return p.IsNull ? Configuration.NullableValues.Double : ToDouble(p.Value);                                       }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Double</c> value.</summary>
		public static Double ToDouble(object p)
		{
			if (p == null) return Configuration.NullableValues.Double;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull   : return Configuration.NullableValues.Double;
				case TypeCode.Double   : return (Double)p;
				case TypeCode.DateTime : return ToDouble((DateTime)p);
				case TypeCode.SByte    : return ToDouble((SByte)   p);
				case TypeCode.Int16    : return ToDouble((Int16)   p);
				case TypeCode.Int32    : return ToDouble((Int32)   p);
				case TypeCode.Int64    : return ToDouble((Int64)   p);
				case TypeCode.Byte     : return ToDouble((Byte)    p);
				case TypeCode.UInt16   : return ToDouble((UInt16)  p);
				case TypeCode.UInt32   : return ToDouble((UInt32)  p);
				case TypeCode.Char     : return ToDouble((Char)    p);
				case TypeCode.UInt64   : return ToDouble((UInt64)  p);
				case TypeCode.Single   : return ToDouble((Single)  p);
				case TypeCode.Decimal  : return ToDouble((Decimal) p);
				case TypeCode.String   : return ToDouble((String)  p);
				case TypeCode.Boolean  : return ToDouble((Boolean) p);
			}

			// Simple Types
			//
			if (p is DateTimeOffset)  return ToDouble((DateTimeOffset) p);
			if (p is TimeSpan)        return ToDouble((TimeSpan)       p);

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)        return ToDouble((Boolean?)       p);
				if (p is Byte?)           return ToDouble((Byte?)          p);
				if (p is Char?)           return ToDouble((Char?)          p);
				if (p is DateTime?)       return ToDouble((DateTime?)      p);
				if (p is DateTimeOffset?) return ToDouble((DateTimeOffset?)p);
				if (p is Decimal?)        return ToDouble((Decimal?)       p);
				if (p is Double?)         return ToDouble((Double?)        p);
				if (p is Int16?)          return ToDouble((Int16?)         p);
				if (p is Int32?)          return ToDouble((Int32?)         p);
				if (p is Int64?)          return ToDouble((Int64?)         p);
				if (p is SByte?)          return ToDouble((SByte?)         p);
				if (p is Single?)         return ToDouble((Single?)        p);
				if (p is TimeSpan?)       return ToDouble((TimeSpan?)      p);
				if (p is UInt16?)         return ToDouble((UInt16?)        p);
				if (p is UInt32?)         return ToDouble((UInt32?)        p);
				if (p is UInt64?)         return ToDouble((UInt64?)        p);
			}

			// Other Types
			//
			if (p is Binary)          return ToDouble((Binary)         p);
			if (p is Byte[])          return ToDouble((Byte[])         p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean)      return ToDouble((SqlBoolean)     p);
				if (p is SqlByte)         return ToDouble((SqlByte)        p);
				if (p is SqlDateTime)     return ToDouble((SqlDateTime)    p);
				if (p is SqlDecimal)      return ToDouble((SqlDecimal)     p);
				if (p is SqlDouble)       return ToDouble((SqlDouble)      p);
				if (p is SqlInt16)        return ToDouble((SqlInt16)       p);
				if (p is SqlInt32)        return ToDouble((SqlInt32)       p);
				if (p is SqlInt64)        return ToDouble((SqlInt64)       p);
				if (p is SqlMoney)        return ToDouble((SqlMoney)       p);
				if (p is SqlSingle)       return ToDouble((SqlSingle)      p);
				if (p is SqlString)       return ToDouble((SqlString)      p);
			}

#endif

			if (p is IConvertible) return ((IConvertible)p).ToDouble(null);

			throw CreateInvalidCastException(p.GetType(), typeof(Double));
		}

		#endregion

		#region Guid

		// Simple Types
		//
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Guid</c> value.</summary>
		public static Guid ToGuid(String    p) { return p == null ? Configuration.NullableValues.Guid : new Guid(p);           }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Guid?</c> to an equivalent <c>Guid</c> value.</summary>
		public static Guid ToGuid(Guid?     p) { return p.HasValue ? p.Value : Configuration.NullableValues.Guid;              }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Guid</c> value.</summary>
		public static Guid ToGuid(Binary    p) { return p == null ? Configuration.NullableValues.Guid : new Guid(p.ToArray()); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>Guid</c> value.</summary>
		public static Guid ToGuid(Byte[]    p) { return p == null ? Configuration.NullableValues.Guid : new Guid(p);           }
		/// <summary>Converts the value from <c>Type</c> to an equivalent <c>Guid</c> value.</summary>
		public static Guid ToGuid(Type      p) { return p == null ? Configuration.NullableValues.Guid : p.GUID;                }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBinary</c> to an equivalent <c>Guid</c> value.</summary>
		public static Guid ToGuid(SqlBinary p) { return p.IsNull  ? Configuration.NullableValues.Guid : p.ToSqlGuid().Value;   }
		/// <summary>Converts the value from <c>SqlGuid</c> to an equivalent <c>Guid</c> value.</summary>
		public static Guid ToGuid(SqlGuid   p) { return p.IsNull ? Configuration.NullableValues.Guid : p.Value;                }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Guid</c> value.</summary>
		public static Guid ToGuid(SqlString p) { return p.IsNull  ? Configuration.NullableValues.Guid : new Guid(p.Value);     }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Guid</c> value.</summary>
		public static Guid ToGuid(object p)
		{
			if (p == null) return Configuration.NullableValues.Guid;

			if (p is Guid) return (Guid)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull : return Configuration.NullableValues.Guid;
				case TypeCode.String : return ToGuid((String)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Guid?)     return ToGuid((Guid?)    p);
			}

			// Other Types
			//
			if (p is Binary)    return ToGuid((Binary)   p);
			if (p is Byte[])    return ToGuid((Byte[])   p);
			if (p is Type)      return ToGuid((Type)     p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBinary) return ToGuid((SqlBinary)p);
				if (p is SqlGuid)   return ToGuid((SqlGuid)  p);
				if (p is SqlString) return ToGuid((SqlString)p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(Guid));
		}

		#endregion

		#region Int16

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(Boolean    p) { return p ? (Int16)1 : (Int16)0;                                                                                }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(Byte       p) { return p;                                                                                                      }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(Char       p) { return checked((Int16)p);                                                                                      }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(Decimal    p) { return checked((Int16)p);                                                                                      }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(Double     p) { return checked((Int16)p);                                                                                      }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(Int32      p) { return checked((Int16)p);                                                                                      }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(Int64      p) { return checked((Int16)p);                                                                                      }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>Int16</c> value.</summary>
		[CLSCompliant(false)]
		public static Int16 ToInt16(SByte      p) { return p;                                                                                                      }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(Single     p) { return checked((Int16)p);                                                                                      }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(String     p) { return p == null? Configuration.NullableValues.Int16 : Int16.Parse(p);                                         }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>Int16</c> value.</summary>
		[CLSCompliant(false)]
		public static Int16 ToInt16(UInt16     p) { return checked((Int16)p);                                                                                      }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>Int16</c> value.</summary>
		[CLSCompliant(false)]
		public static Int16 ToInt16(UInt32     p) { return checked((Int16)p);                                                                                      }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>Int16</c> value.</summary>
		[CLSCompliant(false)]
		public static Int16 ToInt16(UInt64     p) { return checked((Int16)p);                                                                                      }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(Boolean?   p) { return p.HasValue && p.Value ? (Int16)1: (Int16)0;                                                             }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(Byte?      p) { return p.HasValue ? p.Value : Configuration.NullableValues.Int16;                                              }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(Char?      p) { return p.HasValue ? checked((Int16)p.Value) : Configuration.NullableValues.Int16;                              }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(Decimal?   p) { return p.HasValue ? checked((Int16)p.Value) : Configuration.NullableValues.Int16;                              }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(Double?    p) { return p.HasValue ? checked((Int16)p.Value) : Configuration.NullableValues.Int16;                              }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(Int16?     p) { return p.HasValue ? p.Value : Configuration.NullableValues.Int16;                                              }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(Int32?     p) { return p.HasValue ? checked((Int16)p.Value) : Configuration.NullableValues.Int16;                              }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(Int64?     p) { return p.HasValue ? checked((Int16)p.Value) : Configuration.NullableValues.Int16;                              }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>Int16</c> value.</summary>
		[CLSCompliant(false)]
		public static Int16 ToInt16(SByte?     p) { return p.HasValue ? p.Value : Configuration.NullableValues.Int16;                                              }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(Single?    p) { return p.HasValue ? checked((Int16)p.Value) : Configuration.NullableValues.Int16;                              }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>Int16</c> value.</summary>
		[CLSCompliant(false)]
		public static Int16 ToInt16(UInt16?    p) { return p.HasValue ? checked((Int16)p.Value) : Configuration.NullableValues.Int16;                              }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>Int16</c> value.</summary>
		[CLSCompliant(false)]
		public static Int16 ToInt16(UInt32?    p) { return p.HasValue ? checked((Int16)p.Value) : Configuration.NullableValues.Int16;                              }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>Int16</c> value.</summary>
		[CLSCompliant(false)]
		public static Int16 ToInt16(UInt64?    p) { return p.HasValue ? checked((Int16)p.Value) : Configuration.NullableValues.Int16;                              }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(Binary     p) { return p == null || p.Length == 0 ? Configuration.NullableValues.Int16 : BitConverter.ToInt16(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(Byte[]     p) { return p == null || p.Length == 0 ? Configuration.NullableValues.Int16 : BitConverter.ToInt16(p, 0);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(SqlBoolean p) { return p.IsNull ? Configuration.NullableValues.Int16 : ToInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(SqlByte    p) { return p.IsNull ? Configuration.NullableValues.Int16 : p.Value;                                                }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(SqlDecimal p) { return p.IsNull ? Configuration.NullableValues.Int16 : ToInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(SqlDouble  p) { return p.IsNull ? Configuration.NullableValues.Int16 : ToInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(SqlInt16   p) { return p.IsNull ? Configuration.NullableValues.Int16 : p.Value;                                                }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(SqlInt32   p) { return p.IsNull ? Configuration.NullableValues.Int16 : ToInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(SqlInt64   p) { return p.IsNull ? Configuration.NullableValues.Int16 : ToInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(SqlMoney   p) { return p.IsNull ? Configuration.NullableValues.Int16 : ToInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(SqlSingle  p) { return p.IsNull ? Configuration.NullableValues.Int16 : ToInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(SqlString  p) { return p.IsNull ? Configuration.NullableValues.Int16 : ToInt16(p.Value);                                       }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Int16</c> value.</summary>
		public static Int16 ToInt16(object p)
		{
			if (p == null) return Configuration.NullableValues.Int16;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return Configuration.NullableValues.Int16;
				case TypeCode.Int16   : return (Int16)p;
				case TypeCode.SByte   : return ToInt16((SByte)  p);
				case TypeCode.Byte    : return ToInt16((Byte)   p);
				case TypeCode.Int32   : return ToInt16((Int32)  p);
				case TypeCode.Int64   : return ToInt16((Int64)  p);
				case TypeCode.UInt16  : return ToInt16((UInt16) p);
				case TypeCode.UInt32  : return ToInt16((UInt32) p);
				case TypeCode.UInt64  : return ToInt16((UInt64) p);
				case TypeCode.Single  : return ToInt16((Single) p);
				case TypeCode.Double  : return ToInt16((Double) p);
				case TypeCode.Decimal : return ToInt16((Decimal)p);
				case TypeCode.Char    : return ToInt16((Char)   p);
				case TypeCode.String  : return ToInt16((String) p);
				case TypeCode.Boolean : return ToInt16((Boolean)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToInt16((Boolean?)  p);
				if (p is Byte?)      return ToInt16((Byte?)     p);
				if (p is Char?)      return ToInt16((Char?)     p);
				if (p is Decimal?)   return ToInt16((Decimal?)  p);
				if (p is Double?)    return ToInt16((Double?)   p);
				if (p is Int16?)     return ToInt16((Int16?)    p);
				if (p is Int32?)     return ToInt16((Int32?)    p);
				if (p is Int64?)     return ToInt16((Int64?)    p);
				if (p is SByte?)     return ToInt16((SByte?)    p);
				if (p is Single?)    return ToInt16((Single?)   p);
				if (p is UInt16?)    return ToInt16((UInt16?)   p);
				if (p is UInt32?)    return ToInt16((UInt32?)   p);
				if (p is UInt64?)    return ToInt16((UInt64?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToInt16((Binary)    p);
			if (p is Byte[])     return ToInt16((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToInt16((SqlBoolean)p);
				if (p is SqlByte)    return ToInt16((SqlByte)   p);
				if (p is SqlDecimal) return ToInt16((SqlDecimal)p);
				if (p is SqlDouble)  return ToInt16((SqlDouble) p);
				if (p is SqlInt16)   return ToInt16((SqlInt16)  p);
				if (p is SqlInt32)   return ToInt16((SqlInt32)  p);
				if (p is SqlInt64)   return ToInt16((SqlInt64)  p);
				if (p is SqlMoney)   return ToInt16((SqlMoney)  p);
				if (p is SqlSingle)  return ToInt16((SqlSingle) p);
				if (p is SqlString)  return ToInt16((SqlString) p);
			}

#endif

			if (p is IConvertible) return ((IConvertible)p).ToInt16(null);

			throw CreateInvalidCastException(p.GetType(), typeof(Int16));
		}

		#endregion

		#region Int32

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(Boolean    p) { return p ? (Int32)1 : (Int32)0;                                                                                }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(Byte       p) { return p;                                                                                                      }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(Char       p) { return p;                                                                                                      }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(Decimal    p) { return checked((Int32)p);                                                                                      }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(Double     p) { return checked((Int32)p);                                                                                      }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(Int16      p) { return p;                                                                                                      }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(Int64      p) { return checked((Int32)p);                                                                                      }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>Int32</c> value.</summary>
		[CLSCompliant(false)]
		public static Int32 ToInt32(SByte      p) { return p;                                                                                                      }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(Single     p) { return checked((Int32)p);                                                                                      }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(String     p) { return p == null? Configuration.NullableValues.Int32 : Int32.Parse(p);                                         }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>Int32</c> value.</summary>
		[CLSCompliant(false)]
		public static Int32 ToInt32(UInt16     p) { return p;                                                                                                      }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>Int32</c> value.</summary>
		[CLSCompliant(false)]
		public static Int32 ToInt32(UInt32     p) { return checked((Int32)p);                                                                                      }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>Int32</c> value.</summary>
		[CLSCompliant(false)]
		public static Int32 ToInt32(UInt64     p) { return checked((Int32)p);                                                                                      }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(Boolean?   p) { return p.HasValue && p.Value ? (Int32)1: (Int32)0;                                                             }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(Byte?      p) { return p.HasValue ? p.Value : Configuration.NullableValues.Int32;                                              }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(Char?      p) { return p.HasValue ? p.Value : Configuration.NullableValues.Int32;                                              }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(Decimal?   p) { return p.HasValue ? checked((Int32)p.Value) : Configuration.NullableValues.Int32;                              }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(Double?    p) { return p.HasValue ? checked((Int32)p.Value) : Configuration.NullableValues.Int32;                              }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(Int16?     p) { return p.HasValue ? p.Value : Configuration.NullableValues.Int32;                                              }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(Int32?     p) { return p.HasValue ? p.Value : Configuration.NullableValues.Int32;                                              }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(Int64?     p) { return p.HasValue ? checked((Int32)p.Value) : Configuration.NullableValues.Int32;                              }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>Int32</c> value.</summary>
		[CLSCompliant(false)]
		public static Int32 ToInt32(SByte?     p) { return p.HasValue ? p.Value : Configuration.NullableValues.Int32;                                              }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(Single?    p) { return p.HasValue ? checked((Int32)p.Value) : Configuration.NullableValues.Int32;                              }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>Int32</c> value.</summary>
		[CLSCompliant(false)]
		public static Int32 ToInt32(UInt16?    p) { return p.HasValue ? p.Value : Configuration.NullableValues.Int32;                                              }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>Int32</c> value.</summary>
		[CLSCompliant(false)]
		public static Int32 ToInt32(UInt32?    p) { return p.HasValue ? checked((Int32)p.Value) : Configuration.NullableValues.Int32;                              }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>Int32</c> value.</summary>
		[CLSCompliant(false)]
		public static Int32 ToInt32(UInt64?    p) { return p.HasValue ? checked((Int32)p.Value) : Configuration.NullableValues.Int32;                              }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(Binary     p) { return p == null || p.Length == 0 ? Configuration.NullableValues.Int32 : BitConverter.ToInt32(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(Byte[]     p) { return p == null || p.Length == 0 ? Configuration.NullableValues.Int32 : BitConverter.ToInt32(p, 0);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(SqlBoolean p) { return p.IsNull ? Configuration.NullableValues.Int32 : ToInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(SqlByte    p) { return p.IsNull ? Configuration.NullableValues.Int32 : p.Value;                                                }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(SqlDecimal p) { return p.IsNull ? Configuration.NullableValues.Int32 : ToInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(SqlDouble  p) { return p.IsNull ? Configuration.NullableValues.Int32 : ToInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(SqlInt16   p) { return p.IsNull ? Configuration.NullableValues.Int32 : p.Value;                                                }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(SqlInt32   p) { return p.IsNull ? Configuration.NullableValues.Int32 : p.Value;                                                }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(SqlInt64   p) { return p.IsNull ? Configuration.NullableValues.Int32 : ToInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(SqlMoney   p) { return p.IsNull ? Configuration.NullableValues.Int32 : ToInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(SqlSingle  p) { return p.IsNull ? Configuration.NullableValues.Int32 : ToInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(SqlString  p) { return p.IsNull ? Configuration.NullableValues.Int32 : ToInt32(p.Value);                                       }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Int32</c> value.</summary>
		public static Int32 ToInt32(object p)
		{
			if (p == null) return Configuration.NullableValues.Int32;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return Configuration.NullableValues.Int32;
				case TypeCode.Int32   : return (Int32)p;
				case TypeCode.SByte   : return ToInt32((SByte)  p);
				case TypeCode.Int16   : return ToInt32((Int16)  p);
				case TypeCode.Byte    : return ToInt32((Byte)   p);
				case TypeCode.UInt16  : return ToInt32((UInt16) p);
				case TypeCode.Char    : return ToInt32((Char)   p);
				case TypeCode.Int64   : return ToInt32((Int64)  p);
				case TypeCode.UInt32  : return ToInt32((UInt32) p);
				case TypeCode.UInt64  : return ToInt32((UInt64) p);
				case TypeCode.Single  : return ToInt32((Single) p);
				case TypeCode.Double  : return ToInt32((Double) p);
				case TypeCode.Decimal : return ToInt32((Decimal)p);
				case TypeCode.String  : return ToInt32((String) p);
				case TypeCode.Boolean : return ToInt32((Boolean)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToInt32((Boolean?)  p);
				if (p is Byte?)      return ToInt32((Byte?)     p);
				if (p is Char?)      return ToInt32((Char?)     p);
				if (p is Decimal?)   return ToInt32((Decimal?)  p);
				if (p is Double?)    return ToInt32((Double?)   p);
				if (p is Int16?)     return ToInt32((Int16?)    p);
				if (p is Int32?)     return ToInt32((Int32?)    p);
				if (p is Int64?)     return ToInt32((Int64?)    p);
				if (p is SByte?)     return ToInt32((SByte?)    p);
				if (p is Single?)    return ToInt32((Single?)   p);
				if (p is UInt16?)    return ToInt32((UInt16?)   p);
				if (p is UInt32?)    return ToInt32((UInt32?)   p);
				if (p is UInt64?)    return ToInt32((UInt64?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToInt32((Binary)    p);
			if (p is Byte[])     return ToInt32((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToInt32((SqlBoolean)p);
				if (p is SqlByte)    return ToInt32((SqlByte)   p);
				if (p is SqlDecimal) return ToInt32((SqlDecimal)p);
				if (p is SqlDouble)  return ToInt32((SqlDouble) p);
				if (p is SqlInt16)   return ToInt32((SqlInt16)  p);
				if (p is SqlInt32)   return ToInt32((SqlInt32)  p);
				if (p is SqlInt64)   return ToInt32((SqlInt64)  p);
				if (p is SqlMoney)   return ToInt32((SqlMoney)  p);
				if (p is SqlSingle)  return ToInt32((SqlSingle) p);
				if (p is SqlString)  return ToInt32((SqlString) p);
			}

#endif

			if (p is IConvertible) return ((IConvertible)p).ToInt32(null);

			throw CreateInvalidCastException(p.GetType(), typeof(Int32));
		}

		#endregion

		#region Int64

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(Boolean         p) { return p ? (Int64)1 : (Int64)0;                                                                                }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(Byte            p) { return p;                                                                                                      }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(Char            p) { return p;                                                                                                      }
		/// <summary>Converts the value from <c>DateTime</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(DateTime        p) { return (p - DateTime.MinValue).Ticks;                                                                          }
		/// <summary>Converts the value from <c>DateTimeOffset</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(DateTimeOffset  p) { return (p - DateTime.MinValue).Ticks;                                                                          }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(Decimal         p) { return checked((Int64)p);                                                                                      }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(Double          p) { return checked((Int64)p);                                                                                      }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(Int16           p) { return p;                                                                                                      }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(Int32           p) { return p;                                                                                                      }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>Int64</c> value.</summary>
		[CLSCompliant(false)]
		public static Int64 ToInt64(SByte           p) { return p;                                                                                                      }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(Single          p) { return checked((Int64)p);                                                                                      }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(String          p) { return p == null? Configuration.NullableValues.Int64 : Int64.Parse(p);                                         }
		/// <summary>Converts the value from <c>TimeSpan</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(TimeSpan        p) { return p.Ticks;                                                                                                }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>Int64</c> value.</summary>
		[CLSCompliant(false)]
		public static Int64 ToInt64(UInt16          p) { return p;                                                                                                      }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>Int64</c> value.</summary>
		[CLSCompliant(false)]
		public static Int64 ToInt64(UInt32          p) { return p;                                                                                                      }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>Int64</c> value.</summary>
		[CLSCompliant(false)]
		public static Int64 ToInt64(UInt64          p) { return checked((Int64)p);                                                                                      }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(Boolean?        p) { return p.HasValue && p.Value ? (Int64)1: (Int64)0;                                                             }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(Byte?           p) { return p.HasValue ? p.Value : Configuration.NullableValues.Int64;                                              }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(Char?           p) { return p.HasValue ? p.Value : Configuration.NullableValues.Int64;                                              }
		/// <summary>Converts the value from <c>DateTime?</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(DateTime?       p) { return   p.HasValue ? (p.Value - DateTime.MinValue).Ticks : 0;                                                 }
		/// <summary>Converts the value from <c>DateTimeOffset?</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(DateTimeOffset? p) { return   p.HasValue ? (p.Value - DateTime.MinValue).Ticks : 0;                                                 }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(Decimal?        p) { return p.HasValue ? checked((Int64)p.Value) : Configuration.NullableValues.Int64;                              }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(Double?         p) { return p.HasValue ? checked((Int64)p.Value) : Configuration.NullableValues.Int64;                              }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(Int16?          p) { return p.HasValue ? p.Value : Configuration.NullableValues.Int64;                                              }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(Int32?          p) { return p.HasValue ? p.Value : Configuration.NullableValues.Int64;                                              }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(Int64?          p) { return p.HasValue ? p.Value : Configuration.NullableValues.Int64;                                              }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>Int64</c> value.</summary>
		[CLSCompliant(false)]
		public static Int64 ToInt64(SByte?          p) { return p.HasValue ? p.Value : Configuration.NullableValues.Int64;                                              }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(Single?         p) { return p.HasValue ? checked((Int64)p.Value) : Configuration.NullableValues.Int64;                              }
		/// <summary>Converts the value from <c>TimeSpan?</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(TimeSpan?       p) { return p.HasValue ? p.Value.Ticks : 0;                                                                         }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>Int64</c> value.</summary>
		[CLSCompliant(false)]
		public static Int64 ToInt64(UInt16?         p) { return p.HasValue ? p.Value : Configuration.NullableValues.Int64;                                              }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>Int64</c> value.</summary>
		[CLSCompliant(false)]
		public static Int64 ToInt64(UInt32?         p) { return p.HasValue ? p.Value : Configuration.NullableValues.Int64;                                              }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>Int64</c> value.</summary>
		[CLSCompliant(false)]
		public static Int64 ToInt64(UInt64?         p) { return p.HasValue ? checked((Int64)p.Value) : Configuration.NullableValues.Int64;                              }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(Binary          p) { return p == null || p.Length == 0 ? Configuration.NullableValues.Int64 : BitConverter.ToInt64(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(Byte[]          p) { return p == null || p.Length == 0 ? Configuration.NullableValues.Int64 : BitConverter.ToInt64(p, 0);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(SqlBoolean      p) { return p.IsNull ? Configuration.NullableValues.Int64 : ToInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(SqlByte         p) { return p.IsNull ? Configuration.NullableValues.Int64 : p.Value;                                                }
		/// <summary>Converts the value from <c>SqlDateTime</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(SqlDateTime     p) { return p.IsNull ? Configuration.NullableValues.Int64 : ToInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(SqlDecimal      p) { return p.IsNull ? Configuration.NullableValues.Int64 : ToInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(SqlDouble       p) { return p.IsNull ? Configuration.NullableValues.Int64 : ToInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(SqlInt16        p) { return p.IsNull ? Configuration.NullableValues.Int64 : p.Value;                                                }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(SqlInt32        p) { return p.IsNull ? Configuration.NullableValues.Int64 : p.Value;                                                }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(SqlInt64        p) { return p.IsNull ? Configuration.NullableValues.Int64 : p.Value;                                                }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(SqlMoney        p) { return p.IsNull ? Configuration.NullableValues.Int64 : ToInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(SqlSingle       p) { return p.IsNull ? Configuration.NullableValues.Int64 : ToInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(SqlString       p) { return p.IsNull ? Configuration.NullableValues.Int64 : ToInt64(p.Value);                                       }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Int64</c> value.</summary>
		public static Int64 ToInt64(object p)
		{
			if (p == null) return Configuration.NullableValues.Int64;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull   : return Configuration.NullableValues.Int64;
				case TypeCode.Int64    : return (Int64)p;
				case TypeCode.DateTime : return ToInt64((DateTime)p);
				case TypeCode.SByte    : return ToInt64((SByte)   p);
				case TypeCode.Int16    : return ToInt64((Int16)   p);
				case TypeCode.Int32    : return ToInt64((Int32)   p);
				case TypeCode.Byte     : return ToInt64((Byte)    p);
				case TypeCode.UInt16   : return ToInt64((UInt16)  p);
				case TypeCode.UInt32   : return ToInt64((UInt32)  p);
				case TypeCode.Char     : return ToInt64((Char)    p);
				case TypeCode.UInt64   : return ToInt64((UInt64)  p);
				case TypeCode.Single   : return ToInt64((Single)  p);
				case TypeCode.Double   : return ToInt64((Double)  p);
				case TypeCode.Decimal  : return ToInt64((Decimal) p);
				case TypeCode.String   : return ToInt64((String)  p);
				case TypeCode.Boolean  : return ToInt64((Boolean) p);
			}

			// Simple Types
			//
			if (p is DateTimeOffset)  return ToInt64((DateTimeOffset) p);
			if (p is TimeSpan)        return ToInt64((TimeSpan)       p);

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)        return ToInt64((Boolean?)       p);
				if (p is Byte?)           return ToInt64((Byte?)          p);
				if (p is Char?)           return ToInt64((Char?)          p);
				if (p is DateTime?)       return ToInt64((DateTime?)      p);
				if (p is DateTimeOffset?) return ToInt64((DateTimeOffset?)p);
				if (p is Decimal?)        return ToInt64((Decimal?)       p);
				if (p is Double?)         return ToInt64((Double?)        p);
				if (p is Int16?)          return ToInt64((Int16?)         p);
				if (p is Int32?)          return ToInt64((Int32?)         p);
				if (p is Int64?)          return ToInt64((Int64?)         p);
				if (p is SByte?)          return ToInt64((SByte?)         p);
				if (p is Single?)         return ToInt64((Single?)        p);
				if (p is TimeSpan?)       return ToInt64((TimeSpan?)      p);
				if (p is UInt16?)         return ToInt64((UInt16?)        p);
				if (p is UInt32?)         return ToInt64((UInt32?)        p);
				if (p is UInt64?)         return ToInt64((UInt64?)        p);
			}

			// Other Types
			//
			if (p is Binary)          return ToInt64((Binary)         p);
			if (p is Byte[])          return ToInt64((Byte[])         p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean)      return ToInt64((SqlBoolean)     p);
				if (p is SqlByte)         return ToInt64((SqlByte)        p);
				if (p is SqlDateTime)     return ToInt64((SqlDateTime)    p);
				if (p is SqlDecimal)      return ToInt64((SqlDecimal)     p);
				if (p is SqlDouble)       return ToInt64((SqlDouble)      p);
				if (p is SqlInt16)        return ToInt64((SqlInt16)       p);
				if (p is SqlInt32)        return ToInt64((SqlInt32)       p);
				if (p is SqlInt64)        return ToInt64((SqlInt64)       p);
				if (p is SqlMoney)        return ToInt64((SqlMoney)       p);
				if (p is SqlSingle)       return ToInt64((SqlSingle)      p);
				if (p is SqlString)       return ToInt64((SqlString)      p);
			}

#endif

			if (p is IConvertible) return ((IConvertible)p).ToInt64(null);

			throw CreateInvalidCastException(p.GetType(), typeof(Int64));
		}

		#endregion

		#region SByte

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(Boolean    p) { return p ? (SByte)1 : (SByte)0;                                                                          }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(Byte       p) { return checked((SByte)p);                                                                                }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(Char       p) { return checked((SByte)p);                                                                                }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(Decimal    p) { return checked((SByte)p);                                                                                }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(Double     p) { return checked((SByte)p);                                                                                }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(Int16      p) { return checked((SByte)p);                                                                                }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(Int32      p) { return checked((SByte)p);                                                                                }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(Int64      p) { return checked((SByte)p);                                                                                }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(Single     p) { return checked((SByte)p);                                                                                }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(String     p) { return p == null? Configuration.NullableValues.SByte : SByte.Parse(p);                                   }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(UInt16     p) { return checked((SByte)p);                                                                                }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(UInt32     p) { return checked((SByte)p);                                                                                }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(UInt64     p) { return checked((SByte)p);                                                                                }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(Boolean?   p) { return p.HasValue && p.Value ? (SByte)1: (SByte)0;                                                       }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(Byte?      p) { return p.HasValue ? checked((SByte)p.Value) : Configuration.NullableValues.SByte;                        }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(Char?      p) { return p.HasValue ? checked((SByte)p.Value) : Configuration.NullableValues.SByte;                        }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(Decimal?   p) { return p.HasValue ? checked((SByte)p.Value) : Configuration.NullableValues.SByte;                        }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(Double?    p) { return p.HasValue ? checked((SByte)p.Value) : Configuration.NullableValues.SByte;                        }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(Int16?     p) { return p.HasValue ? checked((SByte)p.Value) : Configuration.NullableValues.SByte;                        }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(Int32?     p) { return p.HasValue ? checked((SByte)p.Value) : Configuration.NullableValues.SByte;                        }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(Int64?     p) { return p.HasValue ? checked((SByte)p.Value) : Configuration.NullableValues.SByte;                        }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(SByte?     p) { return p.HasValue ? p.Value : Configuration.NullableValues.SByte;                                        }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(Single?    p) { return p.HasValue ? checked((SByte)p.Value) : Configuration.NullableValues.SByte;                        }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(UInt16?    p) { return p.HasValue ? checked((SByte)p.Value) : Configuration.NullableValues.SByte;                        }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(UInt32?    p) { return p.HasValue ? checked((SByte)p.Value) : Configuration.NullableValues.SByte;                        }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(UInt64?    p) { return p.HasValue ? checked((SByte)p.Value) : Configuration.NullableValues.SByte;                        }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(Binary     p) { return p == null || p.Length == 0 ? Configuration.NullableValues.SByte : checked((SByte)p.ToArray()[0]); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(Byte[]     p) { return p == null || p.Length == 0 ? Configuration.NullableValues.SByte : checked((SByte)p[0]);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(SqlBoolean p) { return p.IsNull ? Configuration.NullableValues.SByte : ToSByte(p.Value);                                 }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(SqlByte    p) { return p.IsNull ? Configuration.NullableValues.SByte : ToSByte(p.Value);                                 }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(SqlDecimal p) { return p.IsNull ? Configuration.NullableValues.SByte : ToSByte(p.Value);                                 }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(SqlDouble  p) { return p.IsNull ? Configuration.NullableValues.SByte : ToSByte(p.Value);                                 }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(SqlInt16   p) { return p.IsNull ? Configuration.NullableValues.SByte : ToSByte(p.Value);                                 }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(SqlInt32   p) { return p.IsNull ? Configuration.NullableValues.SByte : ToSByte(p.Value);                                 }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(SqlInt64   p) { return p.IsNull ? Configuration.NullableValues.SByte : ToSByte(p.Value);                                 }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(SqlMoney   p) { return p.IsNull ? Configuration.NullableValues.SByte : ToSByte(p.Value);                                 }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(SqlSingle  p) { return p.IsNull ? Configuration.NullableValues.SByte : ToSByte(p.Value);                                 }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(SqlString  p) { return p.IsNull ? Configuration.NullableValues.SByte : ToSByte(p.Value);                                 }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>SByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte ToSByte(object p)
		{
			if (p == null) return Configuration.NullableValues.SByte;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return Configuration.NullableValues.SByte;
				case TypeCode.SByte   : return (SByte)p;
				case TypeCode.Int16   : return ToSByte((Int16)  p);
				case TypeCode.Int32   : return ToSByte((Int32)  p);
				case TypeCode.Int64   : return ToSByte((Int64)  p);
				case TypeCode.Byte    : return ToSByte((Byte)   p);
				case TypeCode.UInt16  : return ToSByte((UInt16) p);
				case TypeCode.UInt32  : return ToSByte((UInt32) p);
				case TypeCode.UInt64  : return ToSByte((UInt64) p);
				case TypeCode.Single  : return ToSByte((Single) p);
				case TypeCode.Double  : return ToSByte((Double) p);
				case TypeCode.Decimal : return ToSByte((Decimal)p);
				case TypeCode.Char    : return ToSByte((Char)   p);
				case TypeCode.String  : return ToSByte((String) p);
				case TypeCode.Boolean : return ToSByte((Boolean)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToSByte((Boolean?)  p);
				if (p is Byte?)      return ToSByte((Byte?)     p);
				if (p is Char?)      return ToSByte((Char?)     p);
				if (p is Decimal?)   return ToSByte((Decimal?)  p);
				if (p is Double?)    return ToSByte((Double?)   p);
				if (p is Int16?)     return ToSByte((Int16?)    p);
				if (p is Int32?)     return ToSByte((Int32?)    p);
				if (p is Int64?)     return ToSByte((Int64?)    p);
				if (p is SByte?)     return ToSByte((SByte?)    p);
				if (p is Single?)    return ToSByte((Single?)   p);
				if (p is UInt16?)    return ToSByte((UInt16?)   p);
				if (p is UInt32?)    return ToSByte((UInt32?)   p);
				if (p is UInt64?)    return ToSByte((UInt64?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToSByte((Binary)    p);
			if (p is Byte[])     return ToSByte((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToSByte((SqlBoolean)p);
				if (p is SqlByte)    return ToSByte((SqlByte)   p);
				if (p is SqlDecimal) return ToSByte((SqlDecimal)p);
				if (p is SqlDouble)  return ToSByte((SqlDouble) p);
				if (p is SqlInt16)   return ToSByte((SqlInt16)  p);
				if (p is SqlInt32)   return ToSByte((SqlInt32)  p);
				if (p is SqlInt64)   return ToSByte((SqlInt64)  p);
				if (p is SqlMoney)   return ToSByte((SqlMoney)  p);
				if (p is SqlSingle)  return ToSByte((SqlSingle) p);
				if (p is SqlString)  return ToSByte((SqlString) p);
			}

#endif

			if (p is IConvertible) return ((IConvertible)p).ToSByte(null);

			throw CreateInvalidCastException(p.GetType(), typeof(SByte));
		}

		#endregion

		#region Single

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(Boolean    p) { return p ? (Single)1 : (Single)0;                                                                                }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(Byte       p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(Char       p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(Decimal    p) { return checked((Single)p);                                                                                       }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(Double     p) { return checked((Single)p);                                                                                       }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(Int16      p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(Int32      p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(Int64      p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>Single</c> value.</summary>
		[CLSCompliant(false)]
		public static Single ToSingle(SByte      p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(String     p) { return p == null? Configuration.NullableValues.Single : Single.Parse(p);                                         }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>Single</c> value.</summary>
		[CLSCompliant(false)]
		public static Single ToSingle(UInt16     p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>Single</c> value.</summary>
		[CLSCompliant(false)]
		public static Single ToSingle(UInt32     p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>Single</c> value.</summary>
		[CLSCompliant(false)]
		public static Single ToSingle(UInt64     p) { return p;                                                                                                        }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(Boolean?   p) { return p.HasValue && p.Value ? (Single)1: (Single)0;                                                             }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(Byte?      p) { return p.HasValue ? p.Value : Configuration.NullableValues.Single;                                               }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(Char?      p) { return p.HasValue ? p.Value : Configuration.NullableValues.Single;                                               }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(Decimal?   p) { return p.HasValue ? checked((Single)p.Value) : Configuration.NullableValues.Single;                              }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(Double?    p) { return p.HasValue ? checked((Single)p.Value) : Configuration.NullableValues.Single;                              }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(Int16?     p) { return p.HasValue ? p.Value : Configuration.NullableValues.Single;                                               }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(Int32?     p) { return p.HasValue ? p.Value : Configuration.NullableValues.Single;                                               }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(Int64?     p) { return p.HasValue ? p.Value : Configuration.NullableValues.Single;                                               }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>Single</c> value.</summary>
		[CLSCompliant(false)]
		public static Single ToSingle(SByte?     p) { return p.HasValue ? p.Value : Configuration.NullableValues.Single;                                               }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(Single?    p) { return p.HasValue ? p.Value : Configuration.NullableValues.Single;                                               }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>Single</c> value.</summary>
		[CLSCompliant(false)]
		public static Single ToSingle(UInt16?    p) { return p.HasValue ? p.Value : Configuration.NullableValues.Single;                                               }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>Single</c> value.</summary>
		[CLSCompliant(false)]
		public static Single ToSingle(UInt32?    p) { return p.HasValue ? p.Value : Configuration.NullableValues.Single;                                               }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>Single</c> value.</summary>
		[CLSCompliant(false)]
		public static Single ToSingle(UInt64?    p) { return p.HasValue ? p.Value : Configuration.NullableValues.Single;                                               }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(Binary     p) { return p == null || p.Length == 0 ? Configuration.NullableValues.Single : BitConverter.ToSingle(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(Byte[]     p) { return p == null || p.Length == 0 ? Configuration.NullableValues.Single : BitConverter.ToSingle(p, 0);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(SqlBoolean p) { return p.IsNull ? Configuration.NullableValues.Single : ToSingle(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(SqlByte    p) { return p.IsNull ? Configuration.NullableValues.Single : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(SqlDecimal p) { return p.IsNull ? Configuration.NullableValues.Single : ToSingle(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(SqlDouble  p) { return p.IsNull ? Configuration.NullableValues.Single : ToSingle(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(SqlInt16   p) { return p.IsNull ? Configuration.NullableValues.Single : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(SqlInt32   p) { return p.IsNull ? Configuration.NullableValues.Single : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(SqlInt64   p) { return p.IsNull ? Configuration.NullableValues.Single : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(SqlMoney   p) { return p.IsNull ? Configuration.NullableValues.Single : ToSingle(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(SqlSingle  p) { return p.IsNull ? Configuration.NullableValues.Single : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(SqlString  p) { return p.IsNull ? Configuration.NullableValues.Single : ToSingle(p.Value);                                       }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Single</c> value.</summary>
		public static Single ToSingle(object p)
		{
			if (p == null) return Configuration.NullableValues.Single;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return Configuration.NullableValues.Single;
				case TypeCode.Single  : return (Single)p;
				case TypeCode.SByte   : return ToSingle((SByte)  p);
				case TypeCode.Int16   : return ToSingle((Int16)  p);
				case TypeCode.Int32   : return ToSingle((Int32)  p);
				case TypeCode.Int64   : return ToSingle((Int64)  p);
				case TypeCode.Byte    : return ToSingle((Byte)   p);
				case TypeCode.UInt16  : return ToSingle((UInt16) p);
				case TypeCode.UInt32  : return ToSingle((UInt32) p);
				case TypeCode.Char    : return ToSingle((Char)   p);
				case TypeCode.UInt64  : return ToSingle((UInt64) p);
				case TypeCode.Double  : return ToSingle((Double) p);
				case TypeCode.Decimal : return ToSingle((Decimal)p);
				case TypeCode.String  : return ToSingle((String) p);
				case TypeCode.Boolean : return ToSingle((Boolean)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToSingle((Boolean?)  p);
				if (p is Byte?)      return ToSingle((Byte?)     p);
				if (p is Char?)      return ToSingle((Char?)     p);
				if (p is Decimal?)   return ToSingle((Decimal?)  p);
				if (p is Double?)    return ToSingle((Double?)   p);
				if (p is Int16?)     return ToSingle((Int16?)    p);
				if (p is Int32?)     return ToSingle((Int32?)    p);
				if (p is Int64?)     return ToSingle((Int64?)    p);
				if (p is SByte?)     return ToSingle((SByte?)    p);
				if (p is Single?)    return ToSingle((Single?)   p);
				if (p is UInt16?)    return ToSingle((UInt16?)   p);
				if (p is UInt32?)    return ToSingle((UInt32?)   p);
				if (p is UInt64?)    return ToSingle((UInt64?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToSingle((Binary)    p);
			if (p is Byte[])     return ToSingle((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToSingle((SqlBoolean)p);
				if (p is SqlByte)    return ToSingle((SqlByte)   p);
				if (p is SqlDecimal) return ToSingle((SqlDecimal)p);
				if (p is SqlDouble)  return ToSingle((SqlDouble) p);
				if (p is SqlInt16)   return ToSingle((SqlInt16)  p);
				if (p is SqlInt32)   return ToSingle((SqlInt32)  p);
				if (p is SqlInt64)   return ToSingle((SqlInt64)  p);
				if (p is SqlMoney)   return ToSingle((SqlMoney)  p);
				if (p is SqlSingle)  return ToSingle((SqlSingle) p);
				if (p is SqlString)  return ToSingle((SqlString) p);
			}

#endif

			if (p is IConvertible) return ((IConvertible)p).ToSingle(null);

			throw CreateInvalidCastException(p.GetType(), typeof(Single));
		}

		#endregion

		#region String

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Boolean         p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Byte            p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Char            p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>DateTime</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(DateTime        p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>DateTimeOffset</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(DateTimeOffset  p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Decimal         p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Double          p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>Guid</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Guid            p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Int16           p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Int32           p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Int64           p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>String</c> value.</summary>
		[CLSCompliant(false)]
		public static String ToString(SByte           p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Single          p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>TimeSpan</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(TimeSpan        p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>String</c> value.</summary>
		[CLSCompliant(false)]
		public static String ToString(UInt16          p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>String</c> value.</summary>
		[CLSCompliant(false)]
		public static String ToString(UInt32          p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>String</c> value.</summary>
		[CLSCompliant(false)]
		public static String ToString(UInt64          p) { return p.ToString();                                                                                          }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Boolean?        p) { return p.HasValue ? p.Value.ToString() : Configuration.NullableValues.String;                                 }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Byte?           p) { return p.HasValue ? p.Value.ToString() : Configuration.NullableValues.String;                                 }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Char?           p) { return p.HasValue ? p.Value.ToString() : Configuration.NullableValues.String;                                 }
		/// <summary>Converts the value from <c>DateTime?</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(DateTime?       p) { return p.HasValue ? p.Value.ToString() : Configuration.NullableValues.String;                                 }
		/// <summary>Converts the value from <c>DateTimeOffset?</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(DateTimeOffset? p) { return p.HasValue ? p.Value.ToString() : Configuration.NullableValues.String;                                 }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Decimal?        p) { return p.HasValue ? p.Value.ToString() : Configuration.NullableValues.String;                                 }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Double?         p) { return p.HasValue ? p.Value.ToString() : Configuration.NullableValues.String;                                 }
		/// <summary>Converts the value from <c>Guid?</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Guid?           p) { return p.HasValue ? p.Value.ToString() : Configuration.NullableValues.String;                                 }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Int16?          p) { return p.HasValue ? p.Value.ToString() : Configuration.NullableValues.String;                                 }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Int32?          p) { return p.HasValue ? p.Value.ToString() : Configuration.NullableValues.String;                                 }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Int64?          p) { return p.HasValue ? p.Value.ToString() : Configuration.NullableValues.String;                                 }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>String</c> value.</summary>
		[CLSCompliant(false)]
		public static String ToString(SByte?          p) { return p.HasValue ? p.Value.ToString() : Configuration.NullableValues.String;                                 }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Single?         p) { return p.HasValue ? p.Value.ToString() : Configuration.NullableValues.String;                                 }
		/// <summary>Converts the value from <c>TimeSpan?</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(TimeSpan?       p) { return p.HasValue ? p.Value.ToString() : Configuration.NullableValues.String;                                 }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>String</c> value.</summary>
		[CLSCompliant(false)]
		public static String ToString(UInt16?         p) { return p.HasValue ? p.Value.ToString() : Configuration.NullableValues.String;                                 }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>String</c> value.</summary>
		[CLSCompliant(false)]
		public static String ToString(UInt32?         p) { return p.HasValue ? p.Value.ToString() : Configuration.NullableValues.String;                                 }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>String</c> value.</summary>
		[CLSCompliant(false)]
		public static String ToString(UInt64?         p) { return p.HasValue ? p.Value.ToString() : Configuration.NullableValues.String;                                 }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Binary          p) { return ToString(p.ToArray());                                                                                 }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Byte[]          p) { return p == null ? Configuration.NullableValues.String : System.Text.Encoding.UTF8.GetString(p, 0, p.Length); }
		/// <summary>Converts the value from <c>Type</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(Type            p) { return p == null ? Configuration.NullableValues.String : p.FullName;                                          }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(SqlBoolean      p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(SqlByte         p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>SqlChars</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(SqlChars        p) { return p.IsNull ? Configuration.NullableValues.String : p.ToSqlString().Value;                                }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(SqlDecimal      p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(SqlDouble       p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>SqlGuid</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(SqlGuid         p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(SqlInt16        p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(SqlInt32        p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(SqlInt64        p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(SqlMoney        p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(SqlSingle       p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(SqlString       p) { return p.ToString();                                                                                          }
		/// <summary>Converts the value from <c>SqlXml</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(SqlXml          p) { return p.IsNull ? Configuration.NullableValues.String : p.Value;                                              }

		// Other Types
		//
		/// <summary>Converts the value from <c>XElement</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(XElement        p) { return p == null ? Configuration.NullableValues.String : p.ToString();                                        }
		/// <summary>Converts the value from <c>XmlDocument</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(XmlDocument     p) { return p == null ? Configuration.NullableValues.String : p.InnerXml;                                          }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>String</c> value.</summary>
		public static String ToString(object p)
		{
			if (p == null) return Configuration.NullableValues.String;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull   : return Configuration.NullableValues.String;
				case TypeCode.String   : return (String)p;
				case TypeCode.SByte    : return ToString((SByte)   p);
				case TypeCode.Int16    : return ToString((Int16)   p);
				case TypeCode.Int32    : return ToString((Int32)   p);
				case TypeCode.Int64    : return ToString((Int64)   p);
				case TypeCode.Byte     : return ToString((Byte)    p);
				case TypeCode.UInt16   : return ToString((UInt16)  p);
				case TypeCode.UInt32   : return ToString((UInt32)  p);
				case TypeCode.UInt64   : return ToString((UInt64)  p);
				case TypeCode.Single   : return ToString((Single)  p);
				case TypeCode.Double   : return ToString((Double)  p);
				case TypeCode.Boolean  : return ToString((Boolean) p);
				case TypeCode.Decimal  : return ToString((Decimal) p);
				case TypeCode.Char     : return ToString((Char)    p);
				case TypeCode.DateTime : return ToString((DateTime)p);
			}

			// Simple Types
			//
			if (p is DateTimeOffset)  return ToString((DateTimeOffset) p);
			if (p is Guid)            return ToString((Guid)           p);
			if (p is TimeSpan)        return ToString((TimeSpan)       p);

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)        return ToString((Boolean?)       p);
				if (p is Byte?)           return ToString((Byte?)          p);
				if (p is Char?)           return ToString((Char?)          p);
				if (p is DateTime?)       return ToString((DateTime?)      p);
				if (p is DateTimeOffset?) return ToString((DateTimeOffset?)p);
				if (p is Decimal?)        return ToString((Decimal?)       p);
				if (p is Double?)         return ToString((Double?)        p);
				if (p is Guid?)           return ToString((Guid?)          p);
				if (p is Int16?)          return ToString((Int16?)         p);
				if (p is Int32?)          return ToString((Int32?)         p);
				if (p is Int64?)          return ToString((Int64?)         p);
				if (p is SByte?)          return ToString((SByte?)         p);
				if (p is Single?)         return ToString((Single?)        p);
				if (p is TimeSpan?)       return ToString((TimeSpan?)      p);
				if (p is UInt16?)         return ToString((UInt16?)        p);
				if (p is UInt32?)         return ToString((UInt32?)        p);
				if (p is UInt64?)         return ToString((UInt64?)        p);
			}

			// Other Types
			//
			if (p is Binary)          return ToString((Binary)         p);
			if (p is Byte[])          return ToString((Byte[])         p);
			if (p is Type)            return ToString((Type)           p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean)      return ToString((SqlBoolean)     p);
				if (p is SqlByte)         return ToString((SqlByte)        p);
				if (p is SqlChars)        return ToString((SqlChars)       p);
				if (p is SqlDecimal)      return ToString((SqlDecimal)     p);
				if (p is SqlDouble)       return ToString((SqlDouble)      p);
				if (p is SqlGuid)         return ToString((SqlGuid)        p);
				if (p is SqlInt16)        return ToString((SqlInt16)       p);
				if (p is SqlInt32)        return ToString((SqlInt32)       p);
				if (p is SqlInt64)        return ToString((SqlInt64)       p);
				if (p is SqlMoney)        return ToString((SqlMoney)       p);
				if (p is SqlSingle)       return ToString((SqlSingle)      p);
				if (p is SqlString)       return ToString((SqlString)      p);
				if (p is SqlXml)          return ToString((SqlXml)         p);
			}

			// Other Types
			//
			if (p is XElement)        return ToString((XElement)       p);
			if (p is XmlDocument)     return ToString((XmlDocument)    p);

#endif

			if (p is IConvertible) return ((IConvertible)p).ToString(null);

			return p.ToString();
		}

		#endregion

		#region TimeSpan

		// Simple Types
		//
		/// <summary>Converts the value from <c>DateTime</c> to an equivalent <c>TimeSpan</c> value.</summary>
		public static TimeSpan ToTimeSpan(DateTime        p) { return p - DateTime.MinValue;                                                                                        }
		/// <summary>Converts the value from <c>DateTimeOffset</c> to an equivalent <c>TimeSpan</c> value.</summary>
		public static TimeSpan ToTimeSpan(DateTimeOffset  p) { return p - DateTimeOffset.MinValue;                                                                                  }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>TimeSpan</c> value.</summary>
		public static TimeSpan ToTimeSpan(Double          p) { return TimeSpan.FromDays (p);                                                                                        }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>TimeSpan</c> value.</summary>
		public static TimeSpan ToTimeSpan(Int64           p) { return TimeSpan.FromTicks(p);                                                                                        }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>TimeSpan</c> value.</summary>
		public static TimeSpan ToTimeSpan(String          p) { return p == null? Configuration.NullableValues.TimeSpan : TimeSpan.Parse(p);                                         }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>DateTime?</c> to an equivalent <c>TimeSpan</c> value.</summary>
		public static TimeSpan ToTimeSpan(DateTime?       p) { return p.HasValue ? p.Value - DateTime.MinValue       : Configuration.NullableValues.TimeSpan;                       }
		/// <summary>Converts the value from <c>DateTimeOffset?</c> to an equivalent <c>TimeSpan</c> value.</summary>
		public static TimeSpan ToTimeSpan(DateTimeOffset? p) { return p.HasValue ? p.Value - DateTimeOffset.MinValue : Configuration.NullableValues.TimeSpan;                       }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>TimeSpan</c> value.</summary>
		public static TimeSpan ToTimeSpan(Double?         p) { return p.HasValue ? TimeSpan.FromDays (p.Value)            : Configuration.NullableValues.TimeSpan;                  }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>TimeSpan</c> value.</summary>
		public static TimeSpan ToTimeSpan(Int64?          p) { return p.HasValue ? TimeSpan.FromTicks(p.Value)            : Configuration.NullableValues.TimeSpan;                  }
		/// <summary>Converts the value from <c>TimeSpan?</c> to an equivalent <c>TimeSpan</c> value.</summary>
		public static TimeSpan ToTimeSpan(TimeSpan?       p) { return p.HasValue ? p.Value : Configuration.NullableValues.TimeSpan;                                                 }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>TimeSpan</c> value.</summary>
		public static TimeSpan ToTimeSpan(Binary          p) { return p == null || p.Length == 0? Configuration.NullableValues.TimeSpan : TimeSpan.FromTicks(ToInt64(p.ToArray())); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>TimeSpan</c> value.</summary>
		public static TimeSpan ToTimeSpan(Byte[]          p) { return p == null || p.Length == 0? Configuration.NullableValues.TimeSpan : TimeSpan.FromTicks(ToInt64(p));           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlDateTime</c> to an equivalent <c>TimeSpan</c> value.</summary>
		public static TimeSpan ToTimeSpan(SqlDateTime     p) { return p.IsNull   ? Configuration.NullableValues.TimeSpan : p.Value - DateTime.MinValue;                             }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>TimeSpan</c> value.</summary>
		public static TimeSpan ToTimeSpan(SqlDouble       p) { return p.IsNull   ? Configuration.NullableValues.TimeSpan : TimeSpan.FromDays(p.Value);                              }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>TimeSpan</c> value.</summary>
		public static TimeSpan ToTimeSpan(SqlInt64        p) { return p.IsNull   ? Configuration.NullableValues.TimeSpan : TimeSpan.FromTicks(p.Value);                             }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>TimeSpan</c> value.</summary>
		public static TimeSpan ToTimeSpan(SqlString       p) { return p.IsNull   ? Configuration.NullableValues.TimeSpan : TimeSpan.Parse(p.Value);                                 }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>TimeSpan</c> value.</summary>
		public static TimeSpan ToTimeSpan(object p)
		{
			if (p == null) return Configuration.NullableValues.TimeSpan;

			if (p is TimeSpan) return (TimeSpan)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull   : return Configuration.NullableValues.TimeSpan;
				case TypeCode.DateTime : return ToTimeSpan((DateTime)p);
				case TypeCode.Int64    : return ToTimeSpan((Int64)   p);
				case TypeCode.Double   : return ToTimeSpan((Double)  p);
				case TypeCode.String   : return ToTimeSpan((String)  p);
			}

			// Simple Types
			//
			if (p is DateTimeOffset)  return ToTimeSpan((DateTimeOffset) p);

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is DateTime?)       return ToTimeSpan((DateTime?)      p);
				if (p is DateTimeOffset?) return ToTimeSpan((DateTimeOffset?)p);
				if (p is Double?)         return ToTimeSpan((Double?)        p);
				if (p is Int64?)          return ToTimeSpan((Int64?)         p);
				if (p is TimeSpan?)       return ToTimeSpan((TimeSpan?)      p);
			}

			// Other Types
			//
			if (p is Binary)          return ToTimeSpan((Binary)         p);
			if (p is Byte[])          return ToTimeSpan((Byte[])         p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlDateTime)     return ToTimeSpan((SqlDateTime)    p);
				if (p is SqlDouble)       return ToTimeSpan((SqlDouble)      p);
				if (p is SqlInt64)        return ToTimeSpan((SqlInt64)       p);
				if (p is SqlString)       return ToTimeSpan((SqlString)      p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(TimeSpan));
		}

		#endregion

		#region UInt16

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(Boolean    p) { return p ? (UInt16)1 : (UInt16)0;                                                                                }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(Byte       p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(Char       p) { return checked((UInt16)p);                                                                                       }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(Decimal    p) { return checked((UInt16)p);                                                                                       }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(Double     p) { return checked((UInt16)p);                                                                                       }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(Int16      p) { return checked((UInt16)p);                                                                                       }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(Int32      p) { return checked((UInt16)p);                                                                                       }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(Int64      p) { return checked((UInt16)p);                                                                                       }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(SByte      p) { return checked((UInt16)p);                                                                                       }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(Single     p) { return checked((UInt16)p);                                                                                       }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(String     p) { return p == null? Configuration.NullableValues.UInt16 : UInt16.Parse(p);                                         }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(UInt32     p) { return checked((UInt16)p);                                                                                       }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(UInt64     p) { return checked((UInt16)p);                                                                                       }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(Boolean?   p) { return p.HasValue && p.Value ? (UInt16)1: (UInt16)0;                                                             }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(Byte?      p) { return p.HasValue ? p.Value : Configuration.NullableValues.UInt16;                                               }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(Char?      p) { return p.HasValue ? checked((UInt16)p.Value) : Configuration.NullableValues.UInt16;                              }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(Decimal?   p) { return p.HasValue ? checked((UInt16)p.Value) : Configuration.NullableValues.UInt16;                              }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(Double?    p) { return p.HasValue ? checked((UInt16)p.Value) : Configuration.NullableValues.UInt16;                              }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(Int16?     p) { return p.HasValue ? checked((UInt16)p.Value) : Configuration.NullableValues.UInt16;                              }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(Int32?     p) { return p.HasValue ? checked((UInt16)p.Value) : Configuration.NullableValues.UInt16;                              }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(Int64?     p) { return p.HasValue ? checked((UInt16)p.Value) : Configuration.NullableValues.UInt16;                              }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(SByte?     p) { return p.HasValue ? checked((UInt16)p.Value) : Configuration.NullableValues.UInt16;                              }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(Single?    p) { return p.HasValue ? checked((UInt16)p.Value) : Configuration.NullableValues.UInt16;                              }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(UInt16?    p) { return p.HasValue ? p.Value : Configuration.NullableValues.UInt16;                                               }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(UInt32?    p) { return p.HasValue ? checked((UInt16)p.Value) : Configuration.NullableValues.UInt16;                              }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(UInt64?    p) { return p.HasValue ? checked((UInt16)p.Value) : Configuration.NullableValues.UInt16;                              }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(Binary     p) { return p == null || p.Length == 0 ? Configuration.NullableValues.UInt16 : BitConverter.ToUInt16(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(Byte[]     p) { return p == null || p.Length == 0 ? Configuration.NullableValues.UInt16 : BitConverter.ToUInt16(p, 0);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(SqlBoolean p) { return p.IsNull ? Configuration.NullableValues.UInt16 : ToUInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(SqlByte    p) { return p.IsNull ? Configuration.NullableValues.UInt16 : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(SqlDecimal p) { return p.IsNull ? Configuration.NullableValues.UInt16 : ToUInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(SqlDouble  p) { return p.IsNull ? Configuration.NullableValues.UInt16 : ToUInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(SqlInt16   p) { return p.IsNull ? Configuration.NullableValues.UInt16 : ToUInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(SqlInt32   p) { return p.IsNull ? Configuration.NullableValues.UInt16 : ToUInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(SqlInt64   p) { return p.IsNull ? Configuration.NullableValues.UInt16 : ToUInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(SqlMoney   p) { return p.IsNull ? Configuration.NullableValues.UInt16 : ToUInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(SqlSingle  p) { return p.IsNull ? Configuration.NullableValues.UInt16 : ToUInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(SqlString  p) { return p.IsNull ? Configuration.NullableValues.UInt16 : ToUInt16(p.Value);                                       }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>UInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16 ToUInt16(object p)
		{
			if (p == null) return Configuration.NullableValues.UInt16;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return Configuration.NullableValues.UInt16;
				case TypeCode.UInt16  : return (UInt16)p;
				case TypeCode.Byte    : return ToUInt16((Byte)   p);
				case TypeCode.SByte   : return ToUInt16((SByte)  p);
				case TypeCode.Int16   : return ToUInt16((Int16)  p);
				case TypeCode.Int32   : return ToUInt16((Int32)  p);
				case TypeCode.Int64   : return ToUInt16((Int64)  p);
				case TypeCode.UInt32  : return ToUInt16((UInt32) p);
				case TypeCode.UInt64  : return ToUInt16((UInt64) p);
				case TypeCode.Single  : return ToUInt16((Single) p);
				case TypeCode.Double  : return ToUInt16((Double) p);
				case TypeCode.Decimal : return ToUInt16((Decimal)p);
				case TypeCode.Char    : return ToUInt16((Char)   p);
				case TypeCode.String  : return ToUInt16((String) p);
				case TypeCode.Boolean : return ToUInt16((Boolean)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToUInt16((Boolean?)  p);
				if (p is Byte?)      return ToUInt16((Byte?)     p);
				if (p is Char?)      return ToUInt16((Char?)     p);
				if (p is Decimal?)   return ToUInt16((Decimal?)  p);
				if (p is Double?)    return ToUInt16((Double?)   p);
				if (p is Int16?)     return ToUInt16((Int16?)    p);
				if (p is Int32?)     return ToUInt16((Int32?)    p);
				if (p is Int64?)     return ToUInt16((Int64?)    p);
				if (p is SByte?)     return ToUInt16((SByte?)    p);
				if (p is Single?)    return ToUInt16((Single?)   p);
				if (p is UInt16?)    return ToUInt16((UInt16?)   p);
				if (p is UInt32?)    return ToUInt16((UInt32?)   p);
				if (p is UInt64?)    return ToUInt16((UInt64?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToUInt16((Binary)    p);
			if (p is Byte[])     return ToUInt16((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToUInt16((SqlBoolean)p);
				if (p is SqlByte)    return ToUInt16((SqlByte)   p);
				if (p is SqlDecimal) return ToUInt16((SqlDecimal)p);
				if (p is SqlDouble)  return ToUInt16((SqlDouble) p);
				if (p is SqlInt16)   return ToUInt16((SqlInt16)  p);
				if (p is SqlInt32)   return ToUInt16((SqlInt32)  p);
				if (p is SqlInt64)   return ToUInt16((SqlInt64)  p);
				if (p is SqlMoney)   return ToUInt16((SqlMoney)  p);
				if (p is SqlSingle)  return ToUInt16((SqlSingle) p);
				if (p is SqlString)  return ToUInt16((SqlString) p);
			}

#endif

			if (p is IConvertible) return ((IConvertible)p).ToUInt16(null);

			throw CreateInvalidCastException(p.GetType(), typeof(UInt16));
		}

		#endregion

		#region UInt32

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(Boolean    p) { return p ? (UInt32)1 : (UInt32)0;                                                                                }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(Byte       p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(Char       p) { return checked((UInt32)p);                                                                                       }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(Decimal    p) { return checked((UInt32)p);                                                                                       }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(Double     p) { return checked((UInt32)p);                                                                                       }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(Int16      p) { return checked((UInt32)p);                                                                                       }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(Int32      p) { return checked((UInt32)p);                                                                                       }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(Int64      p) { return checked((UInt32)p);                                                                                       }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(SByte      p) { return checked((UInt32)p);                                                                                       }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(Single     p) { return checked((UInt32)p);                                                                                       }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(String     p) { return p == null? Configuration.NullableValues.UInt32 : UInt32.Parse(p);                                         }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(UInt16     p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(UInt64     p) { return checked((UInt32)p);                                                                                       }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(Boolean?   p) { return p.HasValue && p.Value ? (UInt32)1: (UInt32)0;                                                             }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(Byte?      p) { return p.HasValue ? p.Value : Configuration.NullableValues.UInt32;                                               }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(Char?      p) { return p.HasValue ? checked((UInt32)p.Value) : Configuration.NullableValues.UInt32;                              }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(Decimal?   p) { return p.HasValue ? checked((UInt32)p.Value) : Configuration.NullableValues.UInt32;                              }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(Double?    p) { return p.HasValue ? checked((UInt32)p.Value) : Configuration.NullableValues.UInt32;                              }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(Int16?     p) { return p.HasValue ? checked((UInt32)p.Value) : Configuration.NullableValues.UInt32;                              }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(Int32?     p) { return p.HasValue ? checked((UInt32)p.Value) : Configuration.NullableValues.UInt32;                              }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(Int64?     p) { return p.HasValue ? checked((UInt32)p.Value) : Configuration.NullableValues.UInt32;                              }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(SByte?     p) { return p.HasValue ? checked((UInt32)p.Value) : Configuration.NullableValues.UInt32;                              }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(Single?    p) { return p.HasValue ? checked((UInt32)p.Value) : Configuration.NullableValues.UInt32;                              }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(UInt16?    p) { return p.HasValue ? p.Value : Configuration.NullableValues.UInt32;                                               }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(UInt32?    p) { return p.HasValue ? p.Value : Configuration.NullableValues.UInt32;                                               }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(UInt64?    p) { return p.HasValue ? checked((UInt32)p.Value) : Configuration.NullableValues.UInt32;                              }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(Binary     p) { return p == null || p.Length == 0 ? Configuration.NullableValues.UInt32 : BitConverter.ToUInt32(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(Byte[]     p) { return p == null || p.Length == 0 ? Configuration.NullableValues.UInt32 : BitConverter.ToUInt32(p, 0);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(SqlBoolean p) { return p.IsNull ? Configuration.NullableValues.UInt32 : ToUInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(SqlByte    p) { return p.IsNull ? Configuration.NullableValues.UInt32 : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(SqlDecimal p) { return p.IsNull ? Configuration.NullableValues.UInt32 : ToUInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(SqlDouble  p) { return p.IsNull ? Configuration.NullableValues.UInt32 : ToUInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(SqlInt16   p) { return p.IsNull ? Configuration.NullableValues.UInt32 : ToUInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(SqlInt32   p) { return p.IsNull ? Configuration.NullableValues.UInt32 : ToUInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(SqlInt64   p) { return p.IsNull ? Configuration.NullableValues.UInt32 : ToUInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(SqlMoney   p) { return p.IsNull ? Configuration.NullableValues.UInt32 : ToUInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(SqlSingle  p) { return p.IsNull ? Configuration.NullableValues.UInt32 : ToUInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(SqlString  p) { return p.IsNull ? Configuration.NullableValues.UInt32 : ToUInt32(p.Value);                                       }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>UInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32 ToUInt32(object p)
		{
			if (p == null) return Configuration.NullableValues.UInt32;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return Configuration.NullableValues.UInt32;
				case TypeCode.UInt32  : return (UInt32)p;
				case TypeCode.Byte    : return ToUInt32((Byte)   p);
				case TypeCode.UInt16  : return ToUInt32((UInt16) p);
				case TypeCode.SByte   : return ToUInt32((SByte)  p);
				case TypeCode.Int16   : return ToUInt32((Int16)  p);
				case TypeCode.Int32   : return ToUInt32((Int32)  p);
				case TypeCode.Int64   : return ToUInt32((Int64)  p);
				case TypeCode.UInt64  : return ToUInt32((UInt64) p);
				case TypeCode.Single  : return ToUInt32((Single) p);
				case TypeCode.Double  : return ToUInt32((Double) p);
				case TypeCode.Decimal : return ToUInt32((Decimal)p);
				case TypeCode.Char    : return ToUInt32((Char)   p);
				case TypeCode.String  : return ToUInt32((String) p);
				case TypeCode.Boolean : return ToUInt32((Boolean)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToUInt32((Boolean?)  p);
				if (p is Byte?)      return ToUInt32((Byte?)     p);
				if (p is Char?)      return ToUInt32((Char?)     p);
				if (p is Decimal?)   return ToUInt32((Decimal?)  p);
				if (p is Double?)    return ToUInt32((Double?)   p);
				if (p is Int16?)     return ToUInt32((Int16?)    p);
				if (p is Int32?)     return ToUInt32((Int32?)    p);
				if (p is Int64?)     return ToUInt32((Int64?)    p);
				if (p is SByte?)     return ToUInt32((SByte?)    p);
				if (p is Single?)    return ToUInt32((Single?)   p);
				if (p is UInt16?)    return ToUInt32((UInt16?)   p);
				if (p is UInt32?)    return ToUInt32((UInt32?)   p);
				if (p is UInt64?)    return ToUInt32((UInt64?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToUInt32((Binary)    p);
			if (p is Byte[])     return ToUInt32((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToUInt32((SqlBoolean)p);
				if (p is SqlByte)    return ToUInt32((SqlByte)   p);
				if (p is SqlDecimal) return ToUInt32((SqlDecimal)p);
				if (p is SqlDouble)  return ToUInt32((SqlDouble) p);
				if (p is SqlInt16)   return ToUInt32((SqlInt16)  p);
				if (p is SqlInt32)   return ToUInt32((SqlInt32)  p);
				if (p is SqlInt64)   return ToUInt32((SqlInt64)  p);
				if (p is SqlMoney)   return ToUInt32((SqlMoney)  p);
				if (p is SqlSingle)  return ToUInt32((SqlSingle) p);
				if (p is SqlString)  return ToUInt32((SqlString) p);
			}

#endif

			if (p is IConvertible) return ((IConvertible)p).ToUInt32(null);

			throw CreateInvalidCastException(p.GetType(), typeof(UInt32));
		}

		#endregion

		#region UInt64

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(Boolean    p) { return p ? (UInt64)1 : (UInt64)0;                                                                                }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(Byte       p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(Char       p) { return checked((UInt64)p);                                                                                       }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(Decimal    p) { return checked((UInt64)p);                                                                                       }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(Double     p) { return checked((UInt64)p);                                                                                       }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(Int16      p) { return checked((UInt64)p);                                                                                       }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(Int32      p) { return checked((UInt64)p);                                                                                       }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(Int64      p) { return checked((UInt64)p);                                                                                       }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(SByte      p) { return checked((UInt64)p);                                                                                       }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(Single     p) { return checked((UInt64)p);                                                                                       }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(String     p) { return p == null? Configuration.NullableValues.UInt64 : UInt64.Parse(p);                                         }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(UInt16     p) { return p;                                                                                                        }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(UInt32     p) { return p;                                                                                                        }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(Boolean?   p) { return p.HasValue && p.Value ? (UInt64)1: (UInt64)0;                                                             }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(Byte?      p) { return p.HasValue ? p.Value : Configuration.NullableValues.UInt64;                                               }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(Char?      p) { return p.HasValue ? checked((UInt64)p.Value) : Configuration.NullableValues.UInt64;                              }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(Decimal?   p) { return p.HasValue ? checked((UInt64)p.Value) : Configuration.NullableValues.UInt64;                              }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(Double?    p) { return p.HasValue ? checked((UInt64)p.Value) : Configuration.NullableValues.UInt64;                              }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(Int16?     p) { return p.HasValue ? checked((UInt64)p.Value) : Configuration.NullableValues.UInt64;                              }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(Int32?     p) { return p.HasValue ? checked((UInt64)p.Value) : Configuration.NullableValues.UInt64;                              }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(Int64?     p) { return p.HasValue ? checked((UInt64)p.Value) : Configuration.NullableValues.UInt64;                              }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(SByte?     p) { return p.HasValue ? checked((UInt64)p.Value) : Configuration.NullableValues.UInt64;                              }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(Single?    p) { return p.HasValue ? checked((UInt64)p.Value) : Configuration.NullableValues.UInt64;                              }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(UInt16?    p) { return p.HasValue ? p.Value : Configuration.NullableValues.UInt64;                                               }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(UInt32?    p) { return p.HasValue ? p.Value : Configuration.NullableValues.UInt64;                                               }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(UInt64?    p) { return p.HasValue ? p.Value : Configuration.NullableValues.UInt64;                                               }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(Binary     p) { return p == null || p.Length == 0 ? Configuration.NullableValues.UInt64 : BitConverter.ToUInt64(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(Byte[]     p) { return p == null || p.Length == 0 ? Configuration.NullableValues.UInt64 : BitConverter.ToUInt64(p, 0);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(SqlBoolean p) { return p.IsNull ? Configuration.NullableValues.UInt64 : ToUInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(SqlByte    p) { return p.IsNull ? Configuration.NullableValues.UInt64 : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(SqlDecimal p) { return p.IsNull ? Configuration.NullableValues.UInt64 : ToUInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(SqlDouble  p) { return p.IsNull ? Configuration.NullableValues.UInt64 : ToUInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(SqlInt16   p) { return p.IsNull ? Configuration.NullableValues.UInt64 : ToUInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(SqlInt32   p) { return p.IsNull ? Configuration.NullableValues.UInt64 : ToUInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(SqlInt64   p) { return p.IsNull ? Configuration.NullableValues.UInt64 : ToUInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(SqlMoney   p) { return p.IsNull ? Configuration.NullableValues.UInt64 : ToUInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(SqlSingle  p) { return p.IsNull ? Configuration.NullableValues.UInt64 : ToUInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(SqlString  p) { return p.IsNull ? Configuration.NullableValues.UInt64 : ToUInt64(p.Value);                                       }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>UInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64 ToUInt64(object p)
		{
			if (p == null) return Configuration.NullableValues.UInt64;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return Configuration.NullableValues.UInt64;
				case TypeCode.UInt64  : return (UInt64)p;
				case TypeCode.Byte    : return ToUInt64((Byte)   p);
				case TypeCode.UInt16  : return ToUInt64((UInt16) p);
				case TypeCode.UInt32  : return ToUInt64((UInt32) p);
				case TypeCode.SByte   : return ToUInt64((SByte)  p);
				case TypeCode.Int16   : return ToUInt64((Int16)  p);
				case TypeCode.Int32   : return ToUInt64((Int32)  p);
				case TypeCode.Int64   : return ToUInt64((Int64)  p);
				case TypeCode.Single  : return ToUInt64((Single) p);
				case TypeCode.Double  : return ToUInt64((Double) p);
				case TypeCode.Decimal : return ToUInt64((Decimal)p);
				case TypeCode.Char    : return ToUInt64((Char)   p);
				case TypeCode.String  : return ToUInt64((String) p);
				case TypeCode.Boolean : return ToUInt64((Boolean)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToUInt64((Boolean?)  p);
				if (p is Byte?)      return ToUInt64((Byte?)     p);
				if (p is Char?)      return ToUInt64((Char?)     p);
				if (p is Decimal?)   return ToUInt64((Decimal?)  p);
				if (p is Double?)    return ToUInt64((Double?)   p);
				if (p is Int16?)     return ToUInt64((Int16?)    p);
				if (p is Int32?)     return ToUInt64((Int32?)    p);
				if (p is Int64?)     return ToUInt64((Int64?)    p);
				if (p is SByte?)     return ToUInt64((SByte?)    p);
				if (p is Single?)    return ToUInt64((Single?)   p);
				if (p is UInt16?)    return ToUInt64((UInt16?)   p);
				if (p is UInt32?)    return ToUInt64((UInt32?)   p);
				if (p is UInt64?)    return ToUInt64((UInt64?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToUInt64((Binary)    p);
			if (p is Byte[])     return ToUInt64((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToUInt64((SqlBoolean)p);
				if (p is SqlByte)    return ToUInt64((SqlByte)   p);
				if (p is SqlDecimal) return ToUInt64((SqlDecimal)p);
				if (p is SqlDouble)  return ToUInt64((SqlDouble) p);
				if (p is SqlInt16)   return ToUInt64((SqlInt16)  p);
				if (p is SqlInt32)   return ToUInt64((SqlInt32)  p);
				if (p is SqlInt64)   return ToUInt64((SqlInt64)  p);
				if (p is SqlMoney)   return ToUInt64((SqlMoney)  p);
				if (p is SqlSingle)  return ToUInt64((SqlSingle) p);
				if (p is SqlString)  return ToUInt64((SqlString) p);
			}

#endif

			if (p is IConvertible) return ((IConvertible)p).ToUInt64(null);

			throw CreateInvalidCastException(p.GetType(), typeof(UInt64));
		}

		#endregion

		#endregion

		#region Nullable Types

		#region Boolean?

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(Boolean    p) { return p;                                                                                    }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(Byte       p) { return p != 0;                                                                               }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(Char       p) { return ToBoolean(p);                                                                         }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(Decimal    p) { return p != 0;                                                                               }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(Double     p) { return p != 0;                                                                               }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(Int16      p) { return p != 0;                                                                               }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(Int32      p) { return p != 0;                                                                               }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(Int64      p) { return p != 0;                                                                               }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>Boolean?</c> value.</summary>
		[CLSCompliant(false)]
		public static Boolean? ToNullableBoolean(SByte      p) { return p != 0;                                                                               }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(Single     p) { return p != 0;                                                                               }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(String     p) { return p == null? (Boolean?)null : p.Length == 1 ? ToBoolean(p[0]) : Boolean.Parse(p);       }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>Boolean?</c> value.</summary>
		[CLSCompliant(false)]
		public static Boolean? ToNullableBoolean(UInt16     p) { return p != 0;                                                                               }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>Boolean?</c> value.</summary>
		[CLSCompliant(false)]
		public static Boolean? ToNullableBoolean(UInt32     p) { return p != 0;                                                                               }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>Boolean?</c> value.</summary>
		[CLSCompliant(false)]
		public static Boolean? ToNullableBoolean(UInt64     p) { return p != 0;                                                                               }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(Byte?      p) { return p.HasValue ? p.Value != 0 : (Boolean?)null;                                           }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(Char?      p) { return p.HasValue && ToBoolean(p.Value);                                                     }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(Decimal?   p) { return p.HasValue ? p.Value != 0 : (Boolean?)null;                                           }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(Double?    p) { return p.HasValue ? p.Value != 0 : (Boolean?)null;                                           }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(Int16?     p) { return p.HasValue ? p.Value != 0 : (Boolean?)null;                                           }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(Int32?     p) { return p.HasValue ? p.Value != 0 : (Boolean?)null;                                           }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(Int64?     p) { return p.HasValue ? p.Value != 0 : (Boolean?)null;                                           }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>Boolean?</c> value.</summary>
		[CLSCompliant(false)]
		public static Boolean? ToNullableBoolean(SByte?     p) { return p.HasValue ? p.Value != 0 : (Boolean?)null;                                           }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(Single?    p) { return p.HasValue ? p.Value != 0 : (Boolean?)null;                                           }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>Boolean?</c> value.</summary>
		[CLSCompliant(false)]
		public static Boolean? ToNullableBoolean(UInt16?    p) { return p.HasValue ? p.Value != 0 : (Boolean?)null;                                           }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>Boolean?</c> value.</summary>
		[CLSCompliant(false)]
		public static Boolean? ToNullableBoolean(UInt32?    p) { return p.HasValue ? p.Value != 0 : (Boolean?)null;                                           }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>Boolean?</c> value.</summary>
		[CLSCompliant(false)]
		public static Boolean? ToNullableBoolean(UInt64?    p) { return p.HasValue ? p.Value != 0 : (Boolean?)null;                                           }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(Binary     p) { return p == null || p.Length == 0 ? (Boolean?)null : BitConverter.ToBoolean(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(Byte[]     p) { return p == null || p.Length == 0 ? (Boolean?)null : BitConverter.ToBoolean(p, 0);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(SqlBoolean p) { return p.IsNull ? (Boolean?)null : p.Value;                                                  }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(SqlByte    p) { return p.IsNull ? (Boolean?)null : ToBoolean(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(SqlDecimal p) { return p.IsNull ? (Boolean?)null : ToBoolean(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(SqlDouble  p) { return p.IsNull ? (Boolean?)null : ToBoolean(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(SqlInt16   p) { return p.IsNull ? (Boolean?)null : ToBoolean(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(SqlInt32   p) { return p.IsNull ? (Boolean?)null : ToBoolean(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(SqlInt64   p) { return p.IsNull ? (Boolean?)null : ToBoolean(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(SqlMoney   p) { return p.IsNull ? (Boolean?)null : ToBoolean(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(SqlSingle  p) { return p.IsNull ? (Boolean?)null : ToBoolean(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(SqlString  p) { return p.IsNull ? (Boolean?)null : ToBoolean(p.Value);                                       }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Boolean?</c> value.</summary>
		public static Boolean? ToNullableBoolean(object p)
		{
			if (p == null) return null;

			if (p is Boolean?) return (Boolean?)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull   : return null;
				case TypeCode.String   : return ToNullableBoolean((String)  p);
				case TypeCode.Boolean  : return ToNullableBoolean((Boolean) p);
				case TypeCode.Char     : return ToNullableBoolean((Char)    p);
				case TypeCode.SByte    : return ToNullableBoolean((SByte)   p);
				case TypeCode.Int16    : return ToNullableBoolean((Int16)   p);
				case TypeCode.Int32    : return ToNullableBoolean((Int32)   p);
				case TypeCode.Int64    : return ToNullableBoolean((Int64)   p);
				case TypeCode.Byte     : return ToNullableBoolean((Byte)    p);
				case TypeCode.UInt16   : return ToNullableBoolean((UInt16)  p);
				case TypeCode.UInt32   : return ToNullableBoolean((UInt32)  p);
				case TypeCode.UInt64   : return ToNullableBoolean((UInt64)  p);
				case TypeCode.Single   : return ToNullableBoolean((Single)  p);
				case TypeCode.Double   : return ToNullableBoolean((Double)  p);
				case TypeCode.Decimal  : return ToNullableBoolean((Decimal) p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Byte?)      return ToNullableBoolean((Byte?)     p);
				if (p is Char?)      return ToNullableBoolean((Char?)     p);
				if (p is Decimal?)   return ToNullableBoolean((Decimal?)  p);
				if (p is Double?)    return ToNullableBoolean((Double?)   p);
				if (p is Int16?)     return ToNullableBoolean((Int16?)    p);
				if (p is Int32?)     return ToNullableBoolean((Int32?)    p);
				if (p is Int64?)     return ToNullableBoolean((Int64?)    p);
				if (p is SByte?)     return ToNullableBoolean((SByte?)    p);
				if (p is Single?)    return ToNullableBoolean((Single?)   p);
				if (p is UInt16?)    return ToNullableBoolean((UInt16?)   p);
				if (p is UInt32?)    return ToNullableBoolean((UInt32?)   p);
				if (p is UInt64?)    return ToNullableBoolean((UInt64?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToNullableBoolean((Binary)    p);
			if (p is Byte[])     return ToNullableBoolean((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToNullableBoolean((SqlBoolean)p);
				if (p is SqlByte)    return ToNullableBoolean((SqlByte)   p);
				if (p is SqlDecimal) return ToNullableBoolean((SqlDecimal)p);
				if (p is SqlDouble)  return ToNullableBoolean((SqlDouble) p);
				if (p is SqlInt16)   return ToNullableBoolean((SqlInt16)  p);
				if (p is SqlInt32)   return ToNullableBoolean((SqlInt32)  p);
				if (p is SqlInt64)   return ToNullableBoolean((SqlInt64)  p);
				if (p is SqlMoney)   return ToNullableBoolean((SqlMoney)  p);
				if (p is SqlSingle)  return ToNullableBoolean((SqlSingle) p);
				if (p is SqlString)  return ToNullableBoolean((SqlString) p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(Boolean?));
		}

		#endregion

		#region Byte?

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(Boolean    p) { return p ? (Byte?)1 : (Byte?)0;                                   }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(Byte       p) { return p;                                                         }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(Char       p) { return checked((Byte?)p);                                         }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(Decimal    p) { return checked((Byte?)p);                                         }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(Double     p) { return checked((Byte?)p);                                         }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(Int16      p) { return checked((Byte?)p);                                         }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(Int32      p) { return checked((Byte?)p);                                         }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(Int64      p) { return checked((Byte?)p);                                         }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>Byte?</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte? ToNullableByte(SByte      p) { return checked((Byte?)p);                                         }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(Single     p) { return checked((Byte?)p);                                         }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(String     p) { return p == null? (Byte?)null : Byte.Parse(p);                    }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>Byte?</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte? ToNullableByte(UInt16     p) { return checked((Byte?)p);                                         }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>Byte?</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte? ToNullableByte(UInt32     p) { return checked((Byte?)p);                                         }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>Byte?</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte? ToNullableByte(UInt64     p) { return checked((Byte?)p);                                         }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(Boolean?   p) { return p.HasValue && p.Value ? (Byte?)1: (Byte?)0;                }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(Char?      p) { return p.HasValue ? checked((Byte?)p.Value) : (Byte?)null;        }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(Decimal?   p) { return p.HasValue ? checked((Byte?)p.Value) : (Byte?)null;        }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(Double?    p) { return p.HasValue ? checked((Byte?)p.Value) : (Byte?)null;        }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(Int16?     p) { return p.HasValue ? checked((Byte?)p.Value) : (Byte?)null;        }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(Int32?     p) { return p.HasValue ? checked((Byte?)p.Value) : (Byte?)null;        }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(Int64?     p) { return p.HasValue ? checked((Byte?)p.Value) : (Byte?)null;        }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>Byte?</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte? ToNullableByte(SByte?     p) { return p.HasValue ? checked((Byte?)p.Value) : (Byte?)null;        }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(Single?    p) { return p.HasValue ? checked((Byte?)p.Value) : (Byte?)null;        }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>Byte?</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte? ToNullableByte(UInt16?    p) { return p.HasValue ? checked((Byte?)p.Value) : (Byte?)null;        }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>Byte?</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte? ToNullableByte(UInt32?    p) { return p.HasValue ? checked((Byte?)p.Value) : (Byte?)null;        }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>Byte?</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte? ToNullableByte(UInt64?    p) { return p.HasValue ? checked((Byte?)p.Value) : (Byte?)null;        }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(Binary     p) { return p == null || p.Length == 0 ? (Byte?)null : p.ToArray()[0]; }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(Byte[]     p) { return p == null || p.Length == 0 ? (Byte?)null : p[0];           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(SqlBoolean p) { return p.IsNull ? (Byte?)null : ToByte(p.Value);                  }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(SqlByte    p) { return p.IsNull ? (Byte?)null : p.Value;                          }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(SqlDecimal p) { return p.IsNull ? (Byte?)null : ToByte(p.Value);                  }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(SqlDouble  p) { return p.IsNull ? (Byte?)null : ToByte(p.Value);                  }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(SqlInt16   p) { return p.IsNull ? (Byte?)null : ToByte(p.Value);                  }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(SqlInt32   p) { return p.IsNull ? (Byte?)null : ToByte(p.Value);                  }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(SqlInt64   p) { return p.IsNull ? (Byte?)null : ToByte(p.Value);                  }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(SqlMoney   p) { return p.IsNull ? (Byte?)null : ToByte(p.Value);                  }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(SqlSingle  p) { return p.IsNull ? (Byte?)null : ToByte(p.Value);                  }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(SqlString  p) { return p.IsNull ? (Byte?)null : ToByte(p.Value);                  }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Byte?</c> value.</summary>
		public static Byte? ToNullableByte(object p)
		{
			if (p == null) return null;

			if (p is Byte?) return (Byte?)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return null;
				case TypeCode.Byte    : return ToNullableByte((Byte)   p);
				case TypeCode.SByte   : return ToNullableByte((SByte)  p);
				case TypeCode.Int16   : return ToNullableByte((Int16)  p);
				case TypeCode.Int32   : return ToNullableByte((Int32)  p);
				case TypeCode.Int64   : return ToNullableByte((Int64)  p);
				case TypeCode.UInt16  : return ToNullableByte((UInt16) p);
				case TypeCode.UInt32  : return ToNullableByte((UInt32) p);
				case TypeCode.UInt64  : return ToNullableByte((UInt64) p);
				case TypeCode.Single  : return ToNullableByte((Single) p);
				case TypeCode.Double  : return ToNullableByte((Double) p);
				case TypeCode.Decimal : return ToNullableByte((Decimal)p);
				case TypeCode.Char    : return ToNullableByte((Char)   p);
				case TypeCode.String  : return ToNullableByte((String) p);
				case TypeCode.Boolean : return ToNullableByte((Boolean)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToNullableByte((Boolean?)  p);
				if (p is Char?)      return ToNullableByte((Char?)     p);
				if (p is Decimal?)   return ToNullableByte((Decimal?)  p);
				if (p is Double?)    return ToNullableByte((Double?)   p);
				if (p is Int16?)     return ToNullableByte((Int16?)    p);
				if (p is Int32?)     return ToNullableByte((Int32?)    p);
				if (p is Int64?)     return ToNullableByte((Int64?)    p);
				if (p is SByte?)     return ToNullableByte((SByte?)    p);
				if (p is Single?)    return ToNullableByte((Single?)   p);
				if (p is UInt16?)    return ToNullableByte((UInt16?)   p);
				if (p is UInt32?)    return ToNullableByte((UInt32?)   p);
				if (p is UInt64?)    return ToNullableByte((UInt64?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToNullableByte((Binary)    p);
			if (p is Byte[])     return ToNullableByte((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToNullableByte((SqlBoolean)p);
				if (p is SqlByte)    return ToNullableByte((SqlByte)   p);
				if (p is SqlDecimal) return ToNullableByte((SqlDecimal)p);
				if (p is SqlDouble)  return ToNullableByte((SqlDouble) p);
				if (p is SqlInt16)   return ToNullableByte((SqlInt16)  p);
				if (p is SqlInt32)   return ToNullableByte((SqlInt32)  p);
				if (p is SqlInt64)   return ToNullableByte((SqlInt64)  p);
				if (p is SqlMoney)   return ToNullableByte((SqlMoney)  p);
				if (p is SqlSingle)  return ToNullableByte((SqlSingle) p);
				if (p is SqlString)  return ToNullableByte((SqlString) p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(Byte?));
		}

		#endregion

		#region Char?

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(Boolean    p) { return p ? (Char?)1 : (Char?)0;                                                        }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(Byte       p) { return checked((Char?)p);                                                              }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(Char       p) { return p;                                                                              }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(Decimal    p) { return checked((Char?)p);                                                              }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(Double     p) { return checked((Char?)p);                                                              }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(Int16      p) { return checked((Char?)p);                                                              }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(Int32      p) { return checked((Char?)p);                                                              }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(Int64      p) { return checked((Char?)p);                                                              }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>Char?</c> value.</summary>
		[CLSCompliant(false)]
		public static Char? ToNullableChar(SByte      p) { return checked((Char?)p);                                                              }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(Single     p) { return checked((Char?)p);                                                              }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(String     p) { return string.IsNullOrEmpty(p)? (Char?)0 : p[0];                                       }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>Char?</c> value.</summary>
		[CLSCompliant(false)]
		public static Char? ToNullableChar(UInt16     p) { return checked((Char?)p);                                                              }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>Char?</c> value.</summary>
		[CLSCompliant(false)]
		public static Char? ToNullableChar(UInt32     p) { return checked((Char?)p);                                                              }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>Char?</c> value.</summary>
		[CLSCompliant(false)]
		public static Char? ToNullableChar(UInt64     p) { return checked((Char?)p);                                                              }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(Boolean?   p) { return p.HasValue && p.Value ? (Char?)1: (Char?)0;                                     }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(Byte?      p) { return p.HasValue ? checked((Char?)p.Value) : (Char?)null;                             }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(Decimal?   p) { return p.HasValue ? checked((Char?)p.Value) : (Char?)null;                             }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(Double?    p) { return p.HasValue ? checked((Char?)p.Value) : (Char?)null;                             }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(Int16?     p) { return p.HasValue ? checked((Char?)p.Value) : (Char?)null;                             }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(Int32?     p) { return p.HasValue ? checked((Char?)p.Value) : (Char?)null;                             }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(Int64?     p) { return p.HasValue ? checked((Char?)p.Value) : (Char?)null;                             }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>Char?</c> value.</summary>
		[CLSCompliant(false)]
		public static Char? ToNullableChar(SByte?     p) { return p.HasValue ? checked((Char?)p.Value) : (Char?)null;                             }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(Single?    p) { return p.HasValue ? checked((Char?)p.Value) : (Char?)null;                             }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>Char?</c> value.</summary>
		[CLSCompliant(false)]
		public static Char? ToNullableChar(UInt16?    p) { return p.HasValue ? checked((Char?)p.Value) : (Char?)null;                             }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>Char?</c> value.</summary>
		[CLSCompliant(false)]
		public static Char? ToNullableChar(UInt32?    p) { return p.HasValue ? checked((Char?)p.Value) : (Char?)null;                             }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>Char?</c> value.</summary>
		[CLSCompliant(false)]
		public static Char? ToNullableChar(UInt64?    p) { return p.HasValue ? checked((Char?)p.Value) : (Char?)null;                             }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(Binary     p) { return p == null || p.Length == 0 ? (Char?)null : BitConverter.ToChar(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(Byte[]     p) { return p == null || p.Length == 0 ? (Char?)null : BitConverter.ToChar(p, 0);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(SqlBoolean p) { return p.IsNull ? (Char?)null : ToChar(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(SqlByte    p) { return p.IsNull ? (Char?)null : ToChar(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(SqlDecimal p) { return p.IsNull ? (Char?)null : ToChar(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(SqlDouble  p) { return p.IsNull ? (Char?)null : ToChar(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(SqlInt16   p) { return p.IsNull ? (Char?)null : ToChar(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(SqlInt32   p) { return p.IsNull ? (Char?)null : ToChar(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(SqlInt64   p) { return p.IsNull ? (Char?)null : ToChar(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(SqlMoney   p) { return p.IsNull ? (Char?)null : ToChar(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(SqlSingle  p) { return p.IsNull ? (Char?)null : ToChar(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(SqlString  p) { return p.IsNull ? (Char?)null : ToChar(p.Value);                                       }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Char?</c> value.</summary>
		public static Char? ToNullableChar(object p)
		{
			if (p == null) return null;

			if (p is Char?) return (Char?)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return null;
				case TypeCode.Char    : return ToNullableChar((Char)   p);
				case TypeCode.SByte   : return ToNullableChar((SByte)  p);
				case TypeCode.Int16   : return ToNullableChar((Int16)  p);
				case TypeCode.Int32   : return ToNullableChar((Int32)  p);
				case TypeCode.Int64   : return ToNullableChar((Int64)  p);
				case TypeCode.Byte    : return ToNullableChar((Byte)   p);
				case TypeCode.UInt16  : return ToNullableChar((UInt16) p);
				case TypeCode.UInt32  : return ToNullableChar((UInt32) p);
				case TypeCode.UInt64  : return ToNullableChar((UInt64) p);
				case TypeCode.Single  : return ToNullableChar((Single) p);
				case TypeCode.Double  : return ToNullableChar((Double) p);
				case TypeCode.Decimal : return ToNullableChar((Decimal)p);
				case TypeCode.String  : return ToNullableChar((String) p);
				case TypeCode.Boolean : return ToNullableChar((Boolean)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToNullableChar((Boolean?)  p);
				if (p is Byte?)      return ToNullableChar((Byte?)     p);
				if (p is Decimal?)   return ToNullableChar((Decimal?)  p);
				if (p is Double?)    return ToNullableChar((Double?)   p);
				if (p is Int16?)     return ToNullableChar((Int16?)    p);
				if (p is Int32?)     return ToNullableChar((Int32?)    p);
				if (p is Int64?)     return ToNullableChar((Int64?)    p);
				if (p is SByte?)     return ToNullableChar((SByte?)    p);
				if (p is Single?)    return ToNullableChar((Single?)   p);
				if (p is UInt16?)    return ToNullableChar((UInt16?)   p);
				if (p is UInt32?)    return ToNullableChar((UInt32?)   p);
				if (p is UInt64?)    return ToNullableChar((UInt64?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToNullableChar((Binary)    p);
			if (p is Byte[])     return ToNullableChar((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToNullableChar((SqlBoolean)p);
				if (p is SqlByte)    return ToNullableChar((SqlByte)   p);
				if (p is SqlDecimal) return ToNullableChar((SqlDecimal)p);
				if (p is SqlDouble)  return ToNullableChar((SqlDouble) p);
				if (p is SqlInt16)   return ToNullableChar((SqlInt16)  p);
				if (p is SqlInt32)   return ToNullableChar((SqlInt32)  p);
				if (p is SqlInt64)   return ToNullableChar((SqlInt64)  p);
				if (p is SqlMoney)   return ToNullableChar((SqlMoney)  p);
				if (p is SqlSingle)  return ToNullableChar((SqlSingle) p);
				if (p is SqlString)  return ToNullableChar((SqlString) p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(Char?));
		}

		#endregion

		#region DateTime?

		// Simple Types
		//
		/// <summary>Converts the value from <c>DateTime</c> to an equivalent <c>DateTime?</c> value.</summary>
		public static DateTime? ToNullableDateTime(DateTime        p) { return p;                                                                                          }
		/// <summary>Converts the value from <c>DateTimeOffset</c> to an equivalent <c>DateTime?</c> value.</summary>
		public static DateTime? ToNullableDateTime(DateTimeOffset  p) { return p.LocalDateTime;                                                                            }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>DateTime?</c> value.</summary>
		public static DateTime? ToNullableDateTime(Double          p) { return DateTime.MinValue + TimeSpan.FromDays (p);                                                  }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>DateTime?</c> value.</summary>
		public static DateTime? ToNullableDateTime(Int64           p) { return DateTime.MinValue + TimeSpan.FromTicks(p);                                                  }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>DateTime?</c> value.</summary>
		public static DateTime? ToNullableDateTime(String          p) { return p == null ? (DateTime?)null : DateTime.Parse(p, null, DateTimeStyles.NoCurrentDateDefault); }
		/// <summary>Converts the value from <c>TimeSpan</c> to an equivalent <c>DateTime?</c> value.</summary>
		public static DateTime? ToNullableDateTime(TimeSpan        p) { return DateTime.MinValue + p;                                                                      }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>DateTimeOffset?</c> to an equivalent <c>DateTime?</c> value.</summary>
		public static DateTime? ToNullableDateTime(DateTimeOffset? p) { return p.HasValue ?                     p.Value.LocalDateTime : (DateTime?)null;                   }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>DateTime?</c> value.</summary>
		public static DateTime? ToNullableDateTime(Double?         p) { return p.HasValue ? DateTime.MinValue + TimeSpan.FromDays (p.Value): (DateTime?)null;              }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>DateTime?</c> value.</summary>
		public static DateTime? ToNullableDateTime(Int64?          p) { return p.HasValue ? DateTime.MinValue + TimeSpan.FromTicks(p.Value): (DateTime?)null;              }
		/// <summary>Converts the value from <c>TimeSpan?</c> to an equivalent <c>DateTime?</c> value.</summary>
		public static DateTime? ToNullableDateTime(TimeSpan?       p) { return p.HasValue ? DateTime.MinValue +                    p.Value : (DateTime?)null;              }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>DateTime?</c> value.</summary>
		public static DateTime? ToNullableDateTime(Binary          p) { return p == null || p.Length == 0 ? (DateTime?)null : DateTime.FromBinary(ToInt64(p.ToArray()));   }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>DateTime?</c> value.</summary>
		public static DateTime? ToNullableDateTime(Byte[]          p) { return p == null || p.Length == 0 ? (DateTime?)null : DateTime.FromBinary(ToInt64(p));             }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlDateTime</c> to an equivalent <c>DateTime?</c> value.</summary>
		public static DateTime? ToNullableDateTime(SqlDateTime     p) { return p.IsNull ? (DateTime?)null : p.Value;                                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>DateTime?</c> value.</summary>
		public static DateTime? ToNullableDateTime(SqlDouble       p) { return p.IsNull   ? (DateTime?)null : DateTime.MinValue + TimeSpan.FromDays (p.Value);             }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>DateTime?</c> value.</summary>
		public static DateTime? ToNullableDateTime(SqlInt64        p) { return p.IsNull   ? (DateTime?)null : DateTime.MinValue + TimeSpan.FromTicks(p.Value);             }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>DateTime?</c> value.</summary>
		public static DateTime? ToNullableDateTime(SqlString       p) { return p.IsNull   ? (DateTime?)null :                             ToDateTime(p.Value);             }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>DateTime?</c> value.</summary>
		public static DateTime? ToNullableDateTime(object p)
		{
			if (p == null) return null;

			if (p is DateTime?) return (DateTime?)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull    : return null;
				case TypeCode.DateTime  : return ToNullableDateTime((DateTime) p);
				case TypeCode.String    : return ToNullableDateTime((String)   p);
				case TypeCode.Int64     : return ToNullableDateTime((Int64)    p);
				case TypeCode.Double    : return ToNullableDateTime((Double)   p);
			}

			// Simple Types
			//
			if (p is DateTimeOffset)  return ToNullableDateTime((DateTimeOffset) p);
			if (p is TimeSpan)        return ToNullableDateTime((TimeSpan)       p);

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is DateTimeOffset?) return ToNullableDateTime((DateTimeOffset?)p);
				if (p is Double?)         return ToNullableDateTime((Double?)        p);
				if (p is Int64?)          return ToNullableDateTime((Int64?)         p);
				if (p is TimeSpan?)       return ToNullableDateTime((TimeSpan?)      p);
			}

			// Other Types
			//
			if (p is Binary)          return ToNullableDateTime((Binary)         p);
			if (p is Byte[])          return ToNullableDateTime((Byte[])         p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlDateTime)     return ToNullableDateTime((SqlDateTime)    p);
				if (p is SqlDouble)       return ToNullableDateTime((SqlDouble)      p);
				if (p is SqlInt64)        return ToNullableDateTime((SqlInt64)       p);
				if (p is SqlString)       return ToNullableDateTime((SqlString)      p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(DateTime?));
		}

		#endregion

		#region DateTimeOffset?

		// Simple Types
		//
		/// <summary>Converts the value from <c>DateTime</c> to an equivalent <c>DateTimeOffset?</c> value.</summary>
		public static DateTimeOffset? ToNullableDateTimeOffset(DateTime       p) { return p;                                                                                                 }
		/// <summary>Converts the value from <c>DateTimeOffset</c> to an equivalent <c>DateTimeOffset?</c> value.</summary>
		public static DateTimeOffset? ToNullableDateTimeOffset(DateTimeOffset p) { return p;                                                                                                 }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>DateTimeOffset?</c> value.</summary>
		public static DateTimeOffset? ToNullableDateTimeOffset(Double         p) { return DateTimeOffset.MinValue + TimeSpan.FromDays (p);                                                   }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>DateTimeOffset?</c> value.</summary>
		public static DateTimeOffset? ToNullableDateTimeOffset(Int64          p) { return DateTimeOffset.MinValue + TimeSpan.FromTicks(p);                                                   }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>DateTimeOffset?</c> value.</summary>
		public static DateTimeOffset? ToNullableDateTimeOffset(String         p) { return p == null? (DateTimeOffset?)null : DateTimeOffset.Parse(p);                                        }
		/// <summary>Converts the value from <c>TimeSpan</c> to an equivalent <c>DateTimeOffset?</c> value.</summary>
		public static DateTimeOffset? ToNullableDateTimeOffset(TimeSpan       p) { return DateTimeOffset.MinValue + p;                                                                       }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>DateTime?</c> to an equivalent <c>DateTimeOffset?</c> value.</summary>
		public static DateTimeOffset? ToNullableDateTimeOffset(DateTime?      p) { return p.HasValue ?                                   p.Value : (DateTimeOffset?)null;                    }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>DateTimeOffset?</c> value.</summary>
		public static DateTimeOffset? ToNullableDateTimeOffset(Double?        p) { return p.HasValue ? DateTimeOffset.MinValue + TimeSpan.FromDays (p.Value): (DateTimeOffset?)null;         }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>DateTimeOffset?</c> value.</summary>
		public static DateTimeOffset? ToNullableDateTimeOffset(Int64?         p) { return p.HasValue ? DateTimeOffset.MinValue + TimeSpan.FromTicks(p.Value): (DateTimeOffset?)null;         }
		/// <summary>Converts the value from <c>TimeSpan?</c> to an equivalent <c>DateTimeOffset?</c> value.</summary>
		public static DateTimeOffset? ToNullableDateTimeOffset(TimeSpan?      p) { return p.HasValue ? DateTimeOffset.MinValue +                    p.Value : (DateTimeOffset?)null;         }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>DateTimeOffset?</c> value.</summary>
		public static DateTimeOffset? ToNullableDateTimeOffset(Binary         p) { return p == null || p.Length == 0 ? (DateTimeOffset?)null : new DateTimeOffset?(ToDateTime(p.ToArray())); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>DateTimeOffset?</c> value.</summary>
		public static DateTimeOffset? ToNullableDateTimeOffset(Byte[]         p) { return p == null || p.Length == 0 ? (DateTimeOffset?)null : new DateTimeOffset?(ToDateTime(p));           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlDateTime</c> to an equivalent <c>DateTimeOffset?</c> value.</summary>
		public static DateTimeOffset? ToNullableDateTimeOffset(SqlDateTime    p) { return p.IsNull   ? (DateTimeOffset?)null :                                   p.Value;                    }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>DateTimeOffset?</c> value.</summary>
		public static DateTimeOffset? ToNullableDateTimeOffset(SqlDouble      p) { return p.IsNull   ? (DateTimeOffset?)null : DateTimeOffset.MinValue + TimeSpan.FromDays (p.Value);        }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>DateTimeOffset?</c> value.</summary>
		public static DateTimeOffset? ToNullableDateTimeOffset(SqlInt64       p) { return p.IsNull   ? (DateTimeOffset?)null : DateTimeOffset.MinValue + TimeSpan.FromTicks(p.Value);        }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>DateTimeOffset?</c> value.</summary>
		public static DateTimeOffset? ToNullableDateTimeOffset(SqlString      p) { return p.IsNull   ? (DateTimeOffset?)null :                  ToDateTimeOffset(p.Value);                   }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>DateTimeOffset?</c> value.</summary>
		public static DateTimeOffset? ToNullableDateTimeOffset(object p)
		{
			if (p == null) return null;

			if (p is DateTimeOffset?) return (DateTimeOffset?)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull          : return null;
				case TypeCode.Int64           : return ToNullableDateTimeOffset((Int64)          p);
				case TypeCode.Double          : return ToNullableDateTimeOffset((Double)         p);
				case TypeCode.DateTime        : return ToNullableDateTimeOffset((DateTime)       p);
				case TypeCode.String          : return ToNullableDateTimeOffset((String)         p);
			}

			// Simple Types
			//
			if (p is DateTimeOffset) return ToNullableDateTimeOffset((DateTimeOffset)p);
			if (p is TimeSpan)       return ToNullableDateTimeOffset((TimeSpan)      p);

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is DateTime?)      return ToNullableDateTimeOffset((DateTime?)     p);
				if (p is Double?)        return ToNullableDateTimeOffset((Double?)       p);
				if (p is Int64?)         return ToNullableDateTimeOffset((Int64?)        p);
				if (p is TimeSpan?)      return ToNullableDateTimeOffset((TimeSpan?)     p);
			}

			// Other Types
			//
			if (p is Binary)         return ToNullableDateTimeOffset((Binary)        p);
			if (p is Byte[])         return ToNullableDateTimeOffset((Byte[])        p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlDateTime)    return ToNullableDateTimeOffset((SqlDateTime)   p);
				if (p is SqlDouble)      return ToNullableDateTimeOffset((SqlDouble)     p);
				if (p is SqlInt64)       return ToNullableDateTimeOffset((SqlInt64)      p);
				if (p is SqlString)      return ToNullableDateTimeOffset((SqlString)     p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(DateTimeOffset?));
		}

		#endregion

		#region Decimal?

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(Boolean    p) { return p ? (Decimal?)1 : (Decimal?)0;                              }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(Byte       p) { return p;                                                          }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(Char       p) { return p;                                                          }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(Decimal    p) { return p;                                                          }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(Double     p) { return checked((Decimal?)p);                                       }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(Int16      p) { return p;                                                          }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(Int32      p) { return p;                                                          }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(Int64      p) { return p;                                                          }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>Decimal?</c> value.</summary>
		[CLSCompliant(false)]
		public static Decimal? ToNullableDecimal(SByte      p) { return p;                                                          }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(Single     p) { return checked((Decimal?)p);                                       }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(String     p) { return p == null? (Decimal?)null : Decimal.Parse(p);               }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>Decimal?</c> value.</summary>
		[CLSCompliant(false)]
		public static Decimal? ToNullableDecimal(UInt16     p) { return p;                                                          }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>Decimal?</c> value.</summary>
		[CLSCompliant(false)]
		public static Decimal? ToNullableDecimal(UInt32     p) { return p;                                                          }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>Decimal?</c> value.</summary>
		[CLSCompliant(false)]
		public static Decimal? ToNullableDecimal(UInt64     p) { return p;                                                          }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(Boolean?   p) { return p.HasValue && p.Value ? (Decimal?)1: (Decimal?)0;           }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(Byte?      p) { return p.HasValue ? p.Value : (Decimal?)null;                      }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(Char?      p) { return p.HasValue ? p.Value : (Decimal?)null;                      }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(Double?    p) { return p.HasValue ? checked((Decimal?)p.Value) : (Decimal?)null;   }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(Int16?     p) { return p.HasValue ? p.Value : (Decimal?)null;                      }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(Int32?     p) { return p.HasValue ? p.Value : (Decimal?)null;                      }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(Int64?     p) { return p.HasValue ? p.Value : (Decimal?)null;                      }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>Decimal?</c> value.</summary>
		[CLSCompliant(false)]
		public static Decimal? ToNullableDecimal(SByte?     p) { return p.HasValue ? p.Value : (Decimal?)null;                      }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(Single?    p) { return p.HasValue ? checked((Decimal?)p.Value) : (Decimal?)null;   }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>Decimal?</c> value.</summary>
		[CLSCompliant(false)]
		public static Decimal? ToNullableDecimal(UInt16?    p) { return p.HasValue ? p.Value : (Decimal?)null;                      }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>Decimal?</c> value.</summary>
		[CLSCompliant(false)]
		public static Decimal? ToNullableDecimal(UInt32?    p) { return p.HasValue ? p.Value : (Decimal?)null;                      }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>Decimal?</c> value.</summary>
		[CLSCompliant(false)]
		public static Decimal? ToNullableDecimal(UInt64?    p) { return p.HasValue ? p.Value : (Decimal?)null;                      }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(Binary     p) { return p == null || p.Length == 0 ? (Decimal?)null : ToDecimal(p); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(Byte[]     p) { return p == null || p.Length == 0 ? (Decimal?)null : ToDecimal(p); }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(SqlBoolean p) { return p.IsNull ? (Decimal?)null : ToDecimal(p.Value);             }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(SqlByte    p) { return p.IsNull ? (Decimal?)null : p.Value;                        }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(SqlDecimal p) { return p.IsNull ? (Decimal?)null : p.Value;                        }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(SqlDouble  p) { return p.IsNull ? (Decimal?)null : ToDecimal(p.Value);             }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(SqlInt16   p) { return p.IsNull ? (Decimal?)null : p.Value;                        }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(SqlInt32   p) { return p.IsNull ? (Decimal?)null : p.Value;                        }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(SqlInt64   p) { return p.IsNull ? (Decimal?)null : p.Value;                        }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(SqlMoney   p) { return p.IsNull ? (Decimal?)null : p.Value;                        }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(SqlSingle  p) { return p.IsNull ? (Decimal?)null : ToDecimal(p.Value);             }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(SqlString  p) { return p.IsNull ? (Decimal?)null : ToDecimal(p.Value);             }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Decimal?</c> value.</summary>
		public static Decimal? ToNullableDecimal(object p)
		{
			if (p == null) return null;

			if (p is Decimal?) return (Decimal?)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull   : return null;
				case TypeCode.SByte    : return ToNullableDecimal((SByte)   p);
				case TypeCode.Int16    : return ToNullableDecimal((Int16)   p);
				case TypeCode.Int32    : return ToNullableDecimal((Int32)   p);
				case TypeCode.Int64    : return ToNullableDecimal((Int64)   p);
				case TypeCode.Byte     : return ToNullableDecimal((Byte)    p);
				case TypeCode.UInt16   : return ToNullableDecimal((UInt16)  p);
				case TypeCode.UInt32   : return ToNullableDecimal((UInt32)  p);
				case TypeCode.Char     : return ToNullableDecimal((Char)    p);
				case TypeCode.UInt64   : return ToNullableDecimal((UInt64)  p);
				case TypeCode.Decimal  : return ToNullableDecimal((Decimal) p);
				case TypeCode.Single   : return ToNullableDecimal((Single)  p);
				case TypeCode.Double   : return ToNullableDecimal((Double)  p);
				case TypeCode.String   : return ToNullableDecimal((String)  p);
				case TypeCode.Boolean  : return ToNullableDecimal((Boolean) p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToNullableDecimal((Boolean?)  p);
				if (p is Byte?)      return ToNullableDecimal((Byte?)     p);
				if (p is Char?)      return ToNullableDecimal((Char?)     p);
				if (p is Double?)    return ToNullableDecimal((Double?)   p);
				if (p is Int16?)     return ToNullableDecimal((Int16?)    p);
				if (p is Int32?)     return ToNullableDecimal((Int32?)    p);
				if (p is Int64?)     return ToNullableDecimal((Int64?)    p);
				if (p is SByte?)     return ToNullableDecimal((SByte?)    p);
				if (p is Single?)    return ToNullableDecimal((Single?)   p);
				if (p is UInt16?)    return ToNullableDecimal((UInt16?)   p);
				if (p is UInt32?)    return ToNullableDecimal((UInt32?)   p);
				if (p is UInt64?)    return ToNullableDecimal((UInt64?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToNullableDecimal((Binary)    p);
			if (p is Byte[])     return ToNullableDecimal((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToNullableDecimal((SqlBoolean)p);
				if (p is SqlByte)    return ToNullableDecimal((SqlByte)   p);
				if (p is SqlDecimal) return ToNullableDecimal((SqlDecimal)p);
				if (p is SqlDouble)  return ToNullableDecimal((SqlDouble) p);
				if (p is SqlInt16)   return ToNullableDecimal((SqlInt16)  p);
				if (p is SqlInt32)   return ToNullableDecimal((SqlInt32)  p);
				if (p is SqlInt64)   return ToNullableDecimal((SqlInt64)  p);
				if (p is SqlMoney)   return ToNullableDecimal((SqlMoney)  p);
				if (p is SqlSingle)  return ToNullableDecimal((SqlSingle) p);
				if (p is SqlString)  return ToNullableDecimal((SqlString) p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(Decimal?));
		}

		#endregion

		#region Double?

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(Boolean         p) { return p ? (Double?)1 : (Double?)0;                                                        }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(Byte            p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(Char            p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>DateTime</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(DateTime        p) { return (p - DateTime.MinValue).TotalDays;                                                  }
		/// <summary>Converts the value from <c>DateTimeOffset</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(DateTimeOffset  p) { return (p - DateTimeOffset.MinValue).TotalDays;                                            }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(Decimal         p) { return checked((Double?)p);                                                                }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(Double          p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(Int16           p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(Int32           p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(Int64           p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>Double?</c> value.</summary>
		[CLSCompliant(false)]
		public static Double? ToNullableDouble(SByte           p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(Single          p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(String          p) { return p == null? (Double?)null : Double.Parse(p);                                         }
		/// <summary>Converts the value from <c>TimeSpan</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(TimeSpan        p) { return p.TotalDays;                                                                        }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>Double?</c> value.</summary>
		[CLSCompliant(false)]
		public static Double? ToNullableDouble(UInt16          p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>Double?</c> value.</summary>
		[CLSCompliant(false)]
		public static Double? ToNullableDouble(UInt32          p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>Double?</c> value.</summary>
		[CLSCompliant(false)]
		public static Double? ToNullableDouble(UInt64          p) { return p;                                                                                  }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(Boolean?        p) { return p.HasValue && p.Value ? (Double?)1: (Double?)0;                                     }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(Byte?           p) { return p.HasValue ? p.Value : (Double?)null;                                               }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(Char?           p) { return p.HasValue ? p.Value : (Double?)null;                                               }
		/// <summary>Converts the value from <c>DateTime?</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(DateTime?       p) { return p.HasValue ? (p.Value - DateTime.MinValue).TotalDays : (Double?)null;               }
		/// <summary>Converts the value from <c>DateTimeOffset?</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(DateTimeOffset? p) { return p.HasValue ? (p.Value - DateTimeOffset.MinValue).TotalDays : (Double?)null;         }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(Decimal?        p) { return p.HasValue ? checked((Double?)p.Value) : (Double?)null;                             }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(Int16?          p) { return p.HasValue ? p.Value : (Double?)null;                                               }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(Int32?          p) { return p.HasValue ? p.Value : (Double?)null;                                               }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(Int64?          p) { return p.HasValue ? p.Value : (Double?)null;                                               }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>Double?</c> value.</summary>
		[CLSCompliant(false)]
		public static Double? ToNullableDouble(SByte?          p) { return p.HasValue ? p.Value : (Double?)null;                                               }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(Single?         p) { return p.HasValue ? p.Value : (Double?)null;                                               }
		/// <summary>Converts the value from <c>TimeSpan?</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(TimeSpan?       p) { return p.HasValue ? p.Value.TotalDays : (Double?)null;                                     }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>Double?</c> value.</summary>
		[CLSCompliant(false)]
		public static Double? ToNullableDouble(UInt16?         p) { return p.HasValue ? p.Value : (Double?)null;                                               }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>Double?</c> value.</summary>
		[CLSCompliant(false)]
		public static Double? ToNullableDouble(UInt32?         p) { return p.HasValue ? p.Value : (Double?)null;                                               }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>Double?</c> value.</summary>
		[CLSCompliant(false)]
		public static Double? ToNullableDouble(UInt64?         p) { return p.HasValue ? p.Value : (Double?)null;                                               }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(Binary          p) { return p == null || p.Length == 0 ? (Double?)null : BitConverter.ToDouble(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(Byte[]          p) { return p == null || p.Length == 0 ? (Double?)null : BitConverter.ToDouble(p, 0);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(SqlBoolean      p) { return p.IsNull ? (Double?)null : ToDouble(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(SqlByte         p) { return p.IsNull ? (Double?)null : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlDateTime</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(SqlDateTime     p) { return p.IsNull ? (Double?)null : ToDouble(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(SqlDecimal      p) { return p.IsNull ? (Double?)null : ToDouble(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(SqlDouble       p) { return p.IsNull ? (Double?)null : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(SqlInt16        p) { return p.IsNull ? (Double?)null : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(SqlInt32        p) { return p.IsNull ? (Double?)null : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(SqlInt64        p) { return p.IsNull ? (Double?)null : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(SqlMoney        p) { return p.IsNull ? (Double?)null : ToDouble(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(SqlSingle       p) { return p.IsNull ? (Double?)null : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(SqlString       p) { return p.IsNull ? (Double?)null : ToDouble(p.Value);                                       }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Double?</c> value.</summary>
		public static Double? ToNullableDouble(object p)
		{
			if (p == null) return null;

			if (p is Double?) return (Double?)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull   : return null;
				case TypeCode.DateTime : return ToNullableDouble((DateTime)p);
				case TypeCode.SByte    : return ToNullableDouble((SByte)   p);
				case TypeCode.Int16    : return ToNullableDouble((Int16)   p);
				case TypeCode.Int32    : return ToNullableDouble((Int32)   p);
				case TypeCode.Int64    : return ToNullableDouble((Int64)   p);
				case TypeCode.Byte     : return ToNullableDouble((Byte)    p);
				case TypeCode.UInt16   : return ToNullableDouble((UInt16)  p);
				case TypeCode.UInt32   : return ToNullableDouble((UInt32)  p);
				case TypeCode.Char     : return ToNullableDouble((Char)    p);
				case TypeCode.UInt64   : return ToNullableDouble((UInt64)  p);
				case TypeCode.Single   : return ToNullableDouble((Single)  p);
				case TypeCode.Double   : return ToNullableDouble((Double)  p);
				case TypeCode.Decimal  : return ToNullableDouble((Decimal) p);
				case TypeCode.String   : return ToNullableDouble((String)  p);
				case TypeCode.Boolean  : return ToNullableDouble((Boolean) p);
			}

			// Simple Types
			//
			if (p is DateTimeOffset)  return ToNullableDouble((DateTimeOffset) p);
			if (p is TimeSpan)        return ToNullableDouble((TimeSpan)       p);

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)        return ToNullableDouble((Boolean?)       p);
				if (p is Byte?)           return ToNullableDouble((Byte?)          p);
				if (p is Char?)           return ToNullableDouble((Char?)          p);
				if (p is DateTime?)       return ToNullableDouble((DateTime?)      p);
				if (p is DateTimeOffset?) return ToNullableDouble((DateTimeOffset?)p);
				if (p is Decimal?)        return ToNullableDouble((Decimal?)       p);
				if (p is Int16?)          return ToNullableDouble((Int16?)         p);
				if (p is Int32?)          return ToNullableDouble((Int32?)         p);
				if (p is Int64?)          return ToNullableDouble((Int64?)         p);
				if (p is SByte?)          return ToNullableDouble((SByte?)         p);
				if (p is Single?)         return ToNullableDouble((Single?)        p);
				if (p is TimeSpan?)       return ToNullableDouble((TimeSpan?)      p);
				if (p is UInt16?)         return ToNullableDouble((UInt16?)        p);
				if (p is UInt32?)         return ToNullableDouble((UInt32?)        p);
				if (p is UInt64?)         return ToNullableDouble((UInt64?)        p);
			}

			// Other Types
			//
			if (p is Binary)          return ToNullableDouble((Binary)         p);
			if (p is Byte[])          return ToNullableDouble((Byte[])         p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean)      return ToNullableDouble((SqlBoolean)     p);
				if (p is SqlByte)         return ToNullableDouble((SqlByte)        p);
				if (p is SqlDateTime)     return ToNullableDouble((SqlDateTime)    p);
				if (p is SqlDecimal)      return ToNullableDouble((SqlDecimal)     p);
				if (p is SqlDouble)       return ToNullableDouble((SqlDouble)      p);
				if (p is SqlInt16)        return ToNullableDouble((SqlInt16)       p);
				if (p is SqlInt32)        return ToNullableDouble((SqlInt32)       p);
				if (p is SqlInt64)        return ToNullableDouble((SqlInt64)       p);
				if (p is SqlMoney)        return ToNullableDouble((SqlMoney)       p);
				if (p is SqlSingle)       return ToNullableDouble((SqlSingle)      p);
				if (p is SqlString)       return ToNullableDouble((SqlString)      p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(Double?));
		}

		#endregion

		#region Guid?

		// Simple Types
		//
		/// <summary>Converts the value from <c>Guid</c> to an equivalent <c>Guid?</c> value.</summary>
		public static Guid? ToNullableGuid(Guid      p) { return p;                                               }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Guid?</c> value.</summary>
		public static Guid? ToNullableGuid(String    p) { return p == null ? (Guid?)null : new Guid(p);           }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Guid?</c> value.</summary>
		public static Guid? ToNullableGuid(Binary    p) { return p == null ? (Guid?)null : new Guid(p.ToArray()); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>Guid?</c> value.</summary>
		public static Guid? ToNullableGuid(Byte[]    p) { return p == null ? (Guid?)null : new Guid(p);           }
		/// <summary>Converts the value from <c>Type</c> to an equivalent <c>Guid?</c> value.</summary>
		public static Guid? ToNullableGuid(Type      p) { return p == null ? (Guid?)null : p.GUID;                }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBinary</c> to an equivalent <c>Guid?</c> value.</summary>
		public static Guid? ToNullableGuid(SqlBinary p) { return p.IsNull  ? (Guid?)null : p.ToSqlGuid().Value;   }
		/// <summary>Converts the value from <c>SqlGuid</c> to an equivalent <c>Guid?</c> value.</summary>
		public static Guid? ToNullableGuid(SqlGuid   p) { return p.IsNull ? (Guid?)null : p.Value;                }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Guid?</c> value.</summary>
		public static Guid? ToNullableGuid(SqlString p) { return p.IsNull  ? (Guid?)null : new Guid(p.Value);     }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Guid?</c> value.</summary>
		public static Guid? ToNullableGuid(object p)
		{
			if (p == null) return null;

			if (p is Guid?) return (Guid?)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull : return null;
				case TypeCode.String : return ToNullableGuid((String)p);
			}

			// Simple Types
			//
			if (p is Guid)      return ToNullableGuid((Guid)     p);

			// Other Types
			//
			if (p is Binary)    return ToNullableGuid((Binary)   p);
			if (p is Byte[])    return ToNullableGuid((Byte[])   p);
			if (p is Type)      return ToNullableGuid((Type)     p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBinary) return ToNullableGuid((SqlBinary)p);
				if (p is SqlGuid)   return ToNullableGuid((SqlGuid)  p);
				if (p is SqlString) return ToNullableGuid((SqlString)p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(Guid?));
		}

		#endregion

		#region Int16?

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(Boolean    p) { return p ? (Int16?)1 : (Int16?)0;                                                        }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(Byte       p) { return p;                                                                                }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(Char       p) { return checked((Int16?)p);                                                               }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(Decimal    p) { return checked((Int16?)p);                                                               }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(Double     p) { return checked((Int16?)p);                                                               }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(Int16      p) { return p;                                                                                }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(Int32      p) { return checked((Int16?)p);                                                               }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(Int64      p) { return checked((Int16?)p);                                                               }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>Int16?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int16? ToNullableInt16(SByte      p) { return p;                                                                                }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(Single     p) { return checked((Int16?)p);                                                               }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(String     p) { return p == null? (Int16?)null : Int16.Parse(p);                                         }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>Int16?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int16? ToNullableInt16(UInt16     p) { return checked((Int16?)p);                                                               }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>Int16?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int16? ToNullableInt16(UInt32     p) { return checked((Int16?)p);                                                               }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>Int16?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int16? ToNullableInt16(UInt64     p) { return checked((Int16?)p);                                                               }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(Boolean?   p) { return p.HasValue && p.Value ? (Int16?)1: (Int16?)0;                                     }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(Byte?      p) { return p.HasValue ? p.Value : (Int16?)null;                                              }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(Char?      p) { return p.HasValue ? checked((Int16?)p.Value) : (Int16?)null;                             }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(Decimal?   p) { return p.HasValue ? checked((Int16?)p.Value) : (Int16?)null;                             }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(Double?    p) { return p.HasValue ? checked((Int16?)p.Value) : (Int16?)null;                             }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(Int32?     p) { return p.HasValue ? checked((Int16?)p.Value) : (Int16?)null;                             }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(Int64?     p) { return p.HasValue ? checked((Int16?)p.Value) : (Int16?)null;                             }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>Int16?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int16? ToNullableInt16(SByte?     p) { return p.HasValue ? p.Value : (Int16?)null;                                              }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(Single?    p) { return p.HasValue ? checked((Int16?)p.Value) : (Int16?)null;                             }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>Int16?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int16? ToNullableInt16(UInt16?    p) { return p.HasValue ? checked((Int16?)p.Value) : (Int16?)null;                             }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>Int16?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int16? ToNullableInt16(UInt32?    p) { return p.HasValue ? checked((Int16?)p.Value) : (Int16?)null;                             }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>Int16?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int16? ToNullableInt16(UInt64?    p) { return p.HasValue ? checked((Int16?)p.Value) : (Int16?)null;                             }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(Binary     p) { return p == null || p.Length == 0 ? (Int16?)null : BitConverter.ToInt16(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(Byte[]     p) { return p == null || p.Length == 0 ? (Int16?)null : BitConverter.ToInt16(p, 0);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(SqlBoolean p) { return p.IsNull ? (Int16?)null : ToInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(SqlByte    p) { return p.IsNull ? (Int16?)null : p.Value;                                                }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(SqlDecimal p) { return p.IsNull ? (Int16?)null : ToInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(SqlDouble  p) { return p.IsNull ? (Int16?)null : ToInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(SqlInt16   p) { return p.IsNull ? (Int16?)null : p.Value;                                                }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(SqlInt32   p) { return p.IsNull ? (Int16?)null : ToInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(SqlInt64   p) { return p.IsNull ? (Int16?)null : ToInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(SqlMoney   p) { return p.IsNull ? (Int16?)null : ToInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(SqlSingle  p) { return p.IsNull ? (Int16?)null : ToInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(SqlString  p) { return p.IsNull ? (Int16?)null : ToInt16(p.Value);                                       }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Int16?</c> value.</summary>
		public static Int16? ToNullableInt16(object p)
		{
			if (p == null) return null;

			if (p is Int16?) return (Int16?)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return null;
				case TypeCode.SByte   : return ToNullableInt16((SByte)  p);
				case TypeCode.Int16   : return ToNullableInt16((Int16)  p);
				case TypeCode.Byte    : return ToNullableInt16((Byte)   p);
				case TypeCode.Int32   : return ToNullableInt16((Int32)  p);
				case TypeCode.Int64   : return ToNullableInt16((Int64)  p);
				case TypeCode.UInt16  : return ToNullableInt16((UInt16) p);
				case TypeCode.UInt32  : return ToNullableInt16((UInt32) p);
				case TypeCode.UInt64  : return ToNullableInt16((UInt64) p);
				case TypeCode.Single  : return ToNullableInt16((Single) p);
				case TypeCode.Double  : return ToNullableInt16((Double) p);
				case TypeCode.Decimal : return ToNullableInt16((Decimal)p);
				case TypeCode.Char    : return ToNullableInt16((Char)   p);
				case TypeCode.String  : return ToNullableInt16((String) p);
				case TypeCode.Boolean : return ToNullableInt16((Boolean)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToNullableInt16((Boolean?)  p);
				if (p is Byte?)      return ToNullableInt16((Byte?)     p);
				if (p is Char?)      return ToNullableInt16((Char?)     p);
				if (p is Decimal?)   return ToNullableInt16((Decimal?)  p);
				if (p is Double?)    return ToNullableInt16((Double?)   p);
				if (p is Int32?)     return ToNullableInt16((Int32?)    p);
				if (p is Int64?)     return ToNullableInt16((Int64?)    p);
				if (p is SByte?)     return ToNullableInt16((SByte?)    p);
				if (p is Single?)    return ToNullableInt16((Single?)   p);
				if (p is UInt16?)    return ToNullableInt16((UInt16?)   p);
				if (p is UInt32?)    return ToNullableInt16((UInt32?)   p);
				if (p is UInt64?)    return ToNullableInt16((UInt64?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToNullableInt16((Binary)    p);
			if (p is Byte[])     return ToNullableInt16((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToNullableInt16((SqlBoolean)p);
				if (p is SqlByte)    return ToNullableInt16((SqlByte)   p);
				if (p is SqlDecimal) return ToNullableInt16((SqlDecimal)p);
				if (p is SqlDouble)  return ToNullableInt16((SqlDouble) p);
				if (p is SqlInt16)   return ToNullableInt16((SqlInt16)  p);
				if (p is SqlInt32)   return ToNullableInt16((SqlInt32)  p);
				if (p is SqlInt64)   return ToNullableInt16((SqlInt64)  p);
				if (p is SqlMoney)   return ToNullableInt16((SqlMoney)  p);
				if (p is SqlSingle)  return ToNullableInt16((SqlSingle) p);
				if (p is SqlString)  return ToNullableInt16((SqlString) p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(Int16?));
		}

		#endregion

		#region Int32?

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(Boolean    p) { return p ? (Int32?)1 : (Int32?)0;                                                        }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(Byte       p) { return p;                                                                                }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(Char       p) { return p;                                                                                }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(Decimal    p) { return checked((Int32?)p);                                                               }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(Double     p) { return checked((Int32?)p);                                                               }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(Int16      p) { return p;                                                                                }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(Int32      p) { return p;                                                                                }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(Int64      p) { return checked((Int32?)p);                                                               }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>Int32?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int32? ToNullableInt32(SByte      p) { return p;                                                                                }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(Single     p) { return checked((Int32?)p);                                                               }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(String     p) { return p == null? (Int32?)null : Int32.Parse(p);                                         }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>Int32?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int32? ToNullableInt32(UInt16     p) { return p;                                                                                }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>Int32?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int32? ToNullableInt32(UInt32     p) { return checked((Int32?)p);                                                               }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>Int32?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int32? ToNullableInt32(UInt64     p) { return checked((Int32?)p);                                                               }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(Boolean?   p) { return p.HasValue && p.Value ? (Int32?)1: (Int32?)0;                                     }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(Byte?      p) { return p.HasValue ? p.Value : (Int32?)null;                                              }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(Char?      p) { return p.HasValue ? p.Value : (Int32?)null;                                              }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(Decimal?   p) { return p.HasValue ? checked((Int32?)p.Value) : (Int32?)null;                             }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(Double?    p) { return p.HasValue ? checked((Int32?)p.Value) : (Int32?)null;                             }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(Int16?     p) { return p.HasValue ? p.Value : (Int32?)null;                                              }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(Int64?     p) { return p.HasValue ? checked((Int32?)p.Value) : (Int32?)null;                             }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>Int32?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int32? ToNullableInt32(SByte?     p) { return p.HasValue ? p.Value : (Int32?)null;                                              }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(Single?    p) { return p.HasValue ? checked((Int32?)p.Value) : (Int32?)null;                             }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>Int32?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int32? ToNullableInt32(UInt16?    p) { return p.HasValue ? p.Value : (Int32?)null;                                              }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>Int32?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int32? ToNullableInt32(UInt32?    p) { return p.HasValue ? checked((Int32?)p.Value) : (Int32?)null;                             }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>Int32?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int32? ToNullableInt32(UInt64?    p) { return p.HasValue ? checked((Int32?)p.Value) : (Int32?)null;                             }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(Binary     p) { return p == null || p.Length == 0 ? (Int32?)null : BitConverter.ToInt32(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(Byte[]     p) { return p == null || p.Length == 0 ? (Int32?)null : BitConverter.ToInt32(p, 0);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(SqlBoolean p) { return p.IsNull ? (Int32?)null : ToInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(SqlByte    p) { return p.IsNull ? (Int32?)null : p.Value;                                                }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(SqlDecimal p) { return p.IsNull ? (Int32?)null : ToInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(SqlDouble  p) { return p.IsNull ? (Int32?)null : ToInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(SqlInt16   p) { return p.IsNull ? (Int32?)null : p.Value;                                                }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(SqlInt32   p) { return p.IsNull ? (Int32?)null : p.Value;                                                }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(SqlInt64   p) { return p.IsNull ? (Int32?)null : ToInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(SqlMoney   p) { return p.IsNull ? (Int32?)null : ToInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(SqlSingle  p) { return p.IsNull ? (Int32?)null : ToInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(SqlString  p) { return p.IsNull ? (Int32?)null : ToInt32(p.Value);                                       }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Int32?</c> value.</summary>
		public static Int32? ToNullableInt32(object p)
		{
			if (p == null) return null;

			if (p is Int32?) return (Int32?)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return null;
				case TypeCode.SByte   : return ToNullableInt32((SByte)  p);
				case TypeCode.Int16   : return ToNullableInt32((Int16)  p);
				case TypeCode.Int32   : return ToNullableInt32((Int32)  p);
				case TypeCode.Byte    : return ToNullableInt32((Byte)   p);
				case TypeCode.UInt16  : return ToNullableInt32((UInt16) p);
				case TypeCode.Char    : return ToNullableInt32((Char)   p);
				case TypeCode.Int64   : return ToNullableInt32((Int64)  p);
				case TypeCode.UInt32  : return ToNullableInt32((UInt32) p);
				case TypeCode.UInt64  : return ToNullableInt32((UInt64) p);
				case TypeCode.Single  : return ToNullableInt32((Single) p);
				case TypeCode.Double  : return ToNullableInt32((Double) p);
				case TypeCode.Decimal : return ToNullableInt32((Decimal)p);
				case TypeCode.String  : return ToNullableInt32((String) p);
				case TypeCode.Boolean : return ToNullableInt32((Boolean)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToNullableInt32((Boolean?)  p);
				if (p is Byte?)      return ToNullableInt32((Byte?)     p);
				if (p is Char?)      return ToNullableInt32((Char?)     p);
				if (p is Decimal?)   return ToNullableInt32((Decimal?)  p);
				if (p is Double?)    return ToNullableInt32((Double?)   p);
				if (p is Int16?)     return ToNullableInt32((Int16?)    p);
				if (p is Int64?)     return ToNullableInt32((Int64?)    p);
				if (p is SByte?)     return ToNullableInt32((SByte?)    p);
				if (p is Single?)    return ToNullableInt32((Single?)   p);
				if (p is UInt16?)    return ToNullableInt32((UInt16?)   p);
				if (p is UInt32?)    return ToNullableInt32((UInt32?)   p);
				if (p is UInt64?)    return ToNullableInt32((UInt64?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToNullableInt32((Binary)    p);
			if (p is Byte[])     return ToNullableInt32((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToNullableInt32((SqlBoolean)p);
				if (p is SqlByte)    return ToNullableInt32((SqlByte)   p);
				if (p is SqlDecimal) return ToNullableInt32((SqlDecimal)p);
				if (p is SqlDouble)  return ToNullableInt32((SqlDouble) p);
				if (p is SqlInt16)   return ToNullableInt32((SqlInt16)  p);
				if (p is SqlInt32)   return ToNullableInt32((SqlInt32)  p);
				if (p is SqlInt64)   return ToNullableInt32((SqlInt64)  p);
				if (p is SqlMoney)   return ToNullableInt32((SqlMoney)  p);
				if (p is SqlSingle)  return ToNullableInt32((SqlSingle) p);
				if (p is SqlString)  return ToNullableInt32((SqlString) p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(Int32?));
		}

		#endregion

		#region Int64?

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(Boolean         p) { return p ? (Int64?)1 : (Int64?)0;                                                        }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(Byte            p) { return p;                                                                                }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(Char            p) { return p;                                                                                }
		/// <summary>Converts the value from <c>DateTime</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(DateTime        p) { return (p - DateTime.MinValue).Ticks;                                                    }
		/// <summary>Converts the value from <c>DateTimeOffset</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(DateTimeOffset  p) { return (p - DateTime.MinValue).Ticks;                                                    }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(Decimal         p) { return checked((Int64?)p);                                                               }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(Double          p) { return checked((Int64?)p);                                                               }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(Int16           p) { return p;                                                                                }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(Int32           p) { return p;                                                                                }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(Int64           p) { return p;                                                                                }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>Int64?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int64? ToNullableInt64(SByte           p) { return p;                                                                                }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(Single          p) { return checked((Int64?)p);                                                               }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(String          p) { return p == null? (Int64?)null : Int64.Parse(p);                                         }
		/// <summary>Converts the value from <c>TimeSpan</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(TimeSpan        p) { return p.Ticks;                                                                          }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>Int64?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int64? ToNullableInt64(UInt16          p) { return p;                                                                                }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>Int64?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int64? ToNullableInt64(UInt32          p) { return p;                                                                                }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>Int64?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int64? ToNullableInt64(UInt64          p) { return checked((Int64?)p);                                                               }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(Boolean?        p) { return p.HasValue && p.Value ? (Int64?)1: (Int64?)0;                                     }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(Byte?           p) { return p.HasValue ? p.Value : (Int64?)null;                                              }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(Char?           p) { return p.HasValue ? p.Value : (Int64?)null;                                              }
		/// <summary>Converts the value from <c>DateTime?</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(DateTime?       p) { return p.HasValue ? (p.Value - DateTime.MinValue).Ticks : 0;                             }
		/// <summary>Converts the value from <c>DateTimeOffset?</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(DateTimeOffset? p) { return p.HasValue ? (p.Value - DateTime.MinValue).Ticks : 0;                             }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(Decimal?        p) { return p.HasValue ? checked((Int64?)p.Value) : (Int64?)null;                             }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(Double?         p) { return p.HasValue ? checked((Int64?)p.Value) : (Int64?)null;                             }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(Int16?          p) { return p.HasValue ? p.Value : (Int64?)null;                                              }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(Int32?          p) { return p.HasValue ? p.Value : (Int64?)null;                                              }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>Int64?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int64? ToNullableInt64(SByte?          p) { return p.HasValue ? p.Value : (Int64?)null;                                              }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(Single?         p) { return p.HasValue ? checked((Int64?)p.Value) : (Int64?)null;                             }
		/// <summary>Converts the value from <c>TimeSpan?</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(TimeSpan?       p) { return p.HasValue ? p.Value.Ticks : 0;                                                   }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>Int64?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int64? ToNullableInt64(UInt16?         p) { return p.HasValue ? p.Value : (Int64?)null;                                              }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>Int64?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int64? ToNullableInt64(UInt32?         p) { return p.HasValue ? p.Value : (Int64?)null;                                              }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>Int64?</c> value.</summary>
		[CLSCompliant(false)]
		public static Int64? ToNullableInt64(UInt64?         p) { return p.HasValue ? checked((Int64?)p.Value) : (Int64?)null;                             }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(Binary          p) { return p == null || p.Length == 0 ? (Int64?)null : BitConverter.ToInt64(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(Byte[]          p) { return p == null || p.Length == 0 ? (Int64?)null : BitConverter.ToInt64(p, 0);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(SqlBoolean      p) { return p.IsNull ? (Int64?)null : ToInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(SqlByte         p) { return p.IsNull ? (Int64?)null : p.Value;                                                }
		/// <summary>Converts the value from <c>SqlDateTime</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(SqlDateTime     p) { return p.IsNull ? (Int64?)null : ToInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(SqlDecimal      p) { return p.IsNull ? (Int64?)null : ToInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(SqlDouble       p) { return p.IsNull ? (Int64?)null : ToInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(SqlInt16        p) { return p.IsNull ? (Int64?)null : p.Value;                                                }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(SqlInt32        p) { return p.IsNull ? (Int64?)null : p.Value;                                                }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(SqlInt64        p) { return p.IsNull ? (Int64?)null : p.Value;                                                }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(SqlMoney        p) { return p.IsNull ? (Int64?)null : ToInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(SqlSingle       p) { return p.IsNull ? (Int64?)null : ToInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(SqlString       p) { return p.IsNull ? (Int64?)null : ToInt64(p.Value);                                       }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Int64?</c> value.</summary>
		public static Int64? ToNullableInt64(object p)
		{
			if (p == null) return null;

			if (p is Int64?) return (Int64?)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull   : return null;
				case TypeCode.DateTime : return ToNullableInt64((DateTime)p);
				case TypeCode.SByte    : return ToNullableInt64((SByte)   p);
				case TypeCode.Int16    : return ToNullableInt64((Int16)   p);
				case TypeCode.Int32    : return ToNullableInt64((Int32)   p);
				case TypeCode.Int64    : return ToNullableInt64((Int64)   p);
				case TypeCode.Byte     : return ToNullableInt64((Byte)    p);
				case TypeCode.UInt16   : return ToNullableInt64((UInt16)  p);
				case TypeCode.UInt32   : return ToNullableInt64((UInt32)  p);
				case TypeCode.Char     : return ToNullableInt64((Char)    p);
				case TypeCode.UInt64   : return ToNullableInt64((UInt64)  p);
				case TypeCode.Single   : return ToNullableInt64((Single)  p);
				case TypeCode.Double   : return ToNullableInt64((Double)  p);
				case TypeCode.Decimal  : return ToNullableInt64((Decimal) p);
				case TypeCode.String   : return ToNullableInt64((String)  p);
				case TypeCode.Boolean  : return ToNullableInt64((Boolean) p);
			}

			// Simple Types
			//
			if (p is DateTimeOffset)  return ToNullableInt64((DateTimeOffset) p);
			if (p is TimeSpan)        return ToNullableInt64((TimeSpan)       p);

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)        return ToNullableInt64((Boolean?)       p);
				if (p is Byte?)           return ToNullableInt64((Byte?)          p);
				if (p is Char?)           return ToNullableInt64((Char?)          p);
				if (p is DateTime?)       return ToNullableInt64((DateTime?)      p);
				if (p is DateTimeOffset?) return ToNullableInt64((DateTimeOffset?)p);
				if (p is Decimal?)        return ToNullableInt64((Decimal?)       p);
				if (p is Double?)         return ToNullableInt64((Double?)        p);
				if (p is Int16?)          return ToNullableInt64((Int16?)         p);
				if (p is Int32?)          return ToNullableInt64((Int32?)         p);
				if (p is SByte?)          return ToNullableInt64((SByte?)         p);
				if (p is Single?)         return ToNullableInt64((Single?)        p);
				if (p is TimeSpan?)       return ToNullableInt64((TimeSpan?)      p);
				if (p is UInt16?)         return ToNullableInt64((UInt16?)        p);
				if (p is UInt32?)         return ToNullableInt64((UInt32?)        p);
				if (p is UInt64?)         return ToNullableInt64((UInt64?)        p);
			}

			// Other Types
			//
			if (p is Binary)          return ToNullableInt64((Binary)         p);
			if (p is Byte[])          return ToNullableInt64((Byte[])         p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean)      return ToNullableInt64((SqlBoolean)     p);
				if (p is SqlByte)         return ToNullableInt64((SqlByte)        p);
				if (p is SqlDateTime)     return ToNullableInt64((SqlDateTime)    p);
				if (p is SqlDecimal)      return ToNullableInt64((SqlDecimal)     p);
				if (p is SqlDouble)       return ToNullableInt64((SqlDouble)      p);
				if (p is SqlInt16)        return ToNullableInt64((SqlInt16)       p);
				if (p is SqlInt32)        return ToNullableInt64((SqlInt32)       p);
				if (p is SqlInt64)        return ToNullableInt64((SqlInt64)       p);
				if (p is SqlMoney)        return ToNullableInt64((SqlMoney)       p);
				if (p is SqlSingle)       return ToNullableInt64((SqlSingle)      p);
				if (p is SqlString)       return ToNullableInt64((SqlString)      p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(Int64?));
		}

		#endregion

		#region SByte?

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(Boolean    p) { return p ? (SByte?)1 : (SByte?)0;                                                   }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(Byte       p) { return checked((SByte?)p);                                                          }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(Char       p) { return checked((SByte?)p);                                                          }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(Decimal    p) { return checked((SByte?)p);                                                          }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(Double     p) { return checked((SByte?)p);                                                          }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(Int16      p) { return checked((SByte?)p);                                                          }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(Int32      p) { return checked((SByte?)p);                                                          }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(Int64      p) { return checked((SByte?)p);                                                          }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(SByte      p) { return p;                                                                           }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(Single     p) { return checked((SByte?)p);                                                          }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(String     p) { return p == null? (SByte?)null : SByte.Parse(p);                                    }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(UInt16     p) { return checked((SByte?)p);                                                          }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(UInt32     p) { return checked((SByte?)p);                                                          }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(UInt64     p) { return checked((SByte?)p);                                                          }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(Boolean?   p) { return p.HasValue && p.Value ? (SByte?)1: (SByte?)0;                                }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(Byte?      p) { return p.HasValue ? checked((SByte?)p.Value) : (SByte?)null;                        }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(Char?      p) { return p.HasValue ? checked((SByte?)p.Value) : (SByte?)null;                        }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(Decimal?   p) { return p.HasValue ? checked((SByte?)p.Value) : (SByte?)null;                        }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(Double?    p) { return p.HasValue ? checked((SByte?)p.Value) : (SByte?)null;                        }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(Int16?     p) { return p.HasValue ? checked((SByte?)p.Value) : (SByte?)null;                        }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(Int32?     p) { return p.HasValue ? checked((SByte?)p.Value) : (SByte?)null;                        }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(Int64?     p) { return p.HasValue ? checked((SByte?)p.Value) : (SByte?)null;                        }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(Single?    p) { return p.HasValue ? checked((SByte?)p.Value) : (SByte?)null;                        }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(UInt16?    p) { return p.HasValue ? checked((SByte?)p.Value) : (SByte?)null;                        }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(UInt32?    p) { return p.HasValue ? checked((SByte?)p.Value) : (SByte?)null;                        }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(UInt64?    p) { return p.HasValue ? checked((SByte?)p.Value) : (SByte?)null;                        }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(Binary     p) { return p == null || p.Length == 0 ? (SByte?)null : checked((SByte?)p.ToArray()[0]); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(Byte[]     p) { return p == null || p.Length == 0 ? (SByte?)null : checked((SByte?)p[0]);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(SqlBoolean p) { return p.IsNull ? (SByte?)null : ToSByte(p.Value);                                  }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(SqlByte    p) { return p.IsNull ? (SByte?)null : ToSByte(p.Value);                                  }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(SqlDecimal p) { return p.IsNull ? (SByte?)null : ToSByte(p.Value);                                  }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(SqlDouble  p) { return p.IsNull ? (SByte?)null : ToSByte(p.Value);                                  }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(SqlInt16   p) { return p.IsNull ? (SByte?)null : ToSByte(p.Value);                                  }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(SqlInt32   p) { return p.IsNull ? (SByte?)null : ToSByte(p.Value);                                  }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(SqlInt64   p) { return p.IsNull ? (SByte?)null : ToSByte(p.Value);                                  }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(SqlMoney   p) { return p.IsNull ? (SByte?)null : ToSByte(p.Value);                                  }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(SqlSingle  p) { return p.IsNull ? (SByte?)null : ToSByte(p.Value);                                  }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(SqlString  p) { return p.IsNull ? (SByte?)null : ToSByte(p.Value);                                  }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>SByte?</c> value.</summary>
		[CLSCompliant(false)]
		public static SByte? ToNullableSByte(object p)
		{
			if (p == null) return null;

			if (p is SByte?) return (SByte?)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return null;
				case TypeCode.SByte   : return ToNullableSByte((SByte)  p);
				case TypeCode.Int16   : return ToNullableSByte((Int16)  p);
				case TypeCode.Int32   : return ToNullableSByte((Int32)  p);
				case TypeCode.Int64   : return ToNullableSByte((Int64)  p);
				case TypeCode.Byte    : return ToNullableSByte((Byte)   p);
				case TypeCode.UInt16  : return ToNullableSByte((UInt16) p);
				case TypeCode.UInt32  : return ToNullableSByte((UInt32) p);
				case TypeCode.UInt64  : return ToNullableSByte((UInt64) p);
				case TypeCode.Single  : return ToNullableSByte((Single) p);
				case TypeCode.Double  : return ToNullableSByte((Double) p);
				case TypeCode.Decimal : return ToNullableSByte((Decimal)p);
				case TypeCode.Char    : return ToNullableSByte((Char)   p);
				case TypeCode.String  : return ToNullableSByte((String) p);
				case TypeCode.Boolean : return ToNullableSByte((Boolean)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToNullableSByte((Boolean?)  p);
				if (p is Byte?)      return ToNullableSByte((Byte?)     p);
				if (p is Char?)      return ToNullableSByte((Char?)     p);
				if (p is Decimal?)   return ToNullableSByte((Decimal?)  p);
				if (p is Double?)    return ToNullableSByte((Double?)   p);
				if (p is Int16?)     return ToNullableSByte((Int16?)    p);
				if (p is Int32?)     return ToNullableSByte((Int32?)    p);
				if (p is Int64?)     return ToNullableSByte((Int64?)    p);
				if (p is Single?)    return ToNullableSByte((Single?)   p);
				if (p is UInt16?)    return ToNullableSByte((UInt16?)   p);
				if (p is UInt32?)    return ToNullableSByte((UInt32?)   p);
				if (p is UInt64?)    return ToNullableSByte((UInt64?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToNullableSByte((Binary)    p);
			if (p is Byte[])     return ToNullableSByte((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToNullableSByte((SqlBoolean)p);
				if (p is SqlByte)    return ToNullableSByte((SqlByte)   p);
				if (p is SqlDecimal) return ToNullableSByte((SqlDecimal)p);
				if (p is SqlDouble)  return ToNullableSByte((SqlDouble) p);
				if (p is SqlInt16)   return ToNullableSByte((SqlInt16)  p);
				if (p is SqlInt32)   return ToNullableSByte((SqlInt32)  p);
				if (p is SqlInt64)   return ToNullableSByte((SqlInt64)  p);
				if (p is SqlMoney)   return ToNullableSByte((SqlMoney)  p);
				if (p is SqlSingle)  return ToNullableSByte((SqlSingle) p);
				if (p is SqlString)  return ToNullableSByte((SqlString) p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(SByte?));
		}

		#endregion

		#region Single?

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(Boolean    p) { return p ? (Single?)1 : (Single?)0;                                                        }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(Byte       p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(Char       p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(Decimal    p) { return checked((Single?)p);                                                                }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(Double     p) { return checked((Single?)p);                                                                }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(Int16      p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(Int32      p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(Int64      p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>Single?</c> value.</summary>
		[CLSCompliant(false)]
		public static Single? ToNullableSingle(SByte      p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(Single     p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(String     p) { return p == null? (Single?)null : Single.Parse(p);                                         }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>Single?</c> value.</summary>
		[CLSCompliant(false)]
		public static Single? ToNullableSingle(UInt16     p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>Single?</c> value.</summary>
		[CLSCompliant(false)]
		public static Single? ToNullableSingle(UInt32     p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>Single?</c> value.</summary>
		[CLSCompliant(false)]
		public static Single? ToNullableSingle(UInt64     p) { return p;                                                                                  }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(Boolean?   p) { return p.HasValue && p.Value ? (Single?)1: (Single?)0;                                     }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(Byte?      p) { return p.HasValue ? p.Value : (Single?)null;                                               }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(Char?      p) { return p.HasValue ? p.Value : (Single?)null;                                               }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(Decimal?   p) { return p.HasValue ? checked((Single?)p.Value) : (Single?)null;                             }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(Double?    p) { return p.HasValue ? checked((Single?)p.Value) : (Single?)null;                             }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(Int16?     p) { return p.HasValue ? p.Value : (Single?)null;                                               }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(Int32?     p) { return p.HasValue ? p.Value : (Single?)null;                                               }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(Int64?     p) { return p.HasValue ? p.Value : (Single?)null;                                               }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>Single?</c> value.</summary>
		[CLSCompliant(false)]
		public static Single? ToNullableSingle(SByte?     p) { return p.HasValue ? p.Value : (Single?)null;                                               }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>Single?</c> value.</summary>
		[CLSCompliant(false)]
		public static Single? ToNullableSingle(UInt16?    p) { return p.HasValue ? p.Value : (Single?)null;                                               }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>Single?</c> value.</summary>
		[CLSCompliant(false)]
		public static Single? ToNullableSingle(UInt32?    p) { return p.HasValue ? p.Value : (Single?)null;                                               }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>Single?</c> value.</summary>
		[CLSCompliant(false)]
		public static Single? ToNullableSingle(UInt64?    p) { return p.HasValue ? p.Value : (Single?)null;                                               }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(Binary     p) { return p == null || p.Length == 0 ? (Single?)null : BitConverter.ToSingle(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(Byte[]     p) { return p == null || p.Length == 0 ? (Single?)null : BitConverter.ToSingle(p, 0);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(SqlBoolean p) { return p.IsNull ? (Single?)null : ToSingle(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(SqlByte    p) { return p.IsNull ? (Single?)null : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(SqlDecimal p) { return p.IsNull ? (Single?)null : ToSingle(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(SqlDouble  p) { return p.IsNull ? (Single?)null : ToSingle(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(SqlInt16   p) { return p.IsNull ? (Single?)null : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(SqlInt32   p) { return p.IsNull ? (Single?)null : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(SqlInt64   p) { return p.IsNull ? (Single?)null : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(SqlMoney   p) { return p.IsNull ? (Single?)null : ToSingle(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(SqlSingle  p) { return p.IsNull ? (Single?)null : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(SqlString  p) { return p.IsNull ? (Single?)null : ToSingle(p.Value);                                       }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Single?</c> value.</summary>
		public static Single? ToNullableSingle(object p)
		{
			if (p == null) return null;

			if (p is Single?) return (Single?)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return null;
				case TypeCode.SByte   : return ToNullableSingle((SByte)  p);
				case TypeCode.Int16   : return ToNullableSingle((Int16)  p);
				case TypeCode.Int32   : return ToNullableSingle((Int32)  p);
				case TypeCode.Int64   : return ToNullableSingle((Int64)  p);
				case TypeCode.Byte    : return ToNullableSingle((Byte)   p);
				case TypeCode.UInt16  : return ToNullableSingle((UInt16) p);
				case TypeCode.UInt32  : return ToNullableSingle((UInt32) p);
				case TypeCode.Char    : return ToNullableSingle((Char)   p);
				case TypeCode.UInt64  : return ToNullableSingle((UInt64) p);
				case TypeCode.Single  : return ToNullableSingle((Single) p);
				case TypeCode.Double  : return ToNullableSingle((Double) p);
				case TypeCode.Decimal : return ToNullableSingle((Decimal)p);
				case TypeCode.String  : return ToNullableSingle((String) p);
				case TypeCode.Boolean : return ToNullableSingle((Boolean)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToNullableSingle((Boolean?)  p);
				if (p is Byte?)      return ToNullableSingle((Byte?)     p);
				if (p is Char?)      return ToNullableSingle((Char?)     p);
				if (p is Decimal?)   return ToNullableSingle((Decimal?)  p);
				if (p is Double?)    return ToNullableSingle((Double?)   p);
				if (p is Int16?)     return ToNullableSingle((Int16?)    p);
				if (p is Int32?)     return ToNullableSingle((Int32?)    p);
				if (p is Int64?)     return ToNullableSingle((Int64?)    p);
				if (p is SByte?)     return ToNullableSingle((SByte?)    p);
				if (p is UInt16?)    return ToNullableSingle((UInt16?)   p);
				if (p is UInt32?)    return ToNullableSingle((UInt32?)   p);
				if (p is UInt64?)    return ToNullableSingle((UInt64?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToNullableSingle((Binary)    p);
			if (p is Byte[])     return ToNullableSingle((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToNullableSingle((SqlBoolean)p);
				if (p is SqlByte)    return ToNullableSingle((SqlByte)   p);
				if (p is SqlDecimal) return ToNullableSingle((SqlDecimal)p);
				if (p is SqlDouble)  return ToNullableSingle((SqlDouble) p);
				if (p is SqlInt16)   return ToNullableSingle((SqlInt16)  p);
				if (p is SqlInt32)   return ToNullableSingle((SqlInt32)  p);
				if (p is SqlInt64)   return ToNullableSingle((SqlInt64)  p);
				if (p is SqlMoney)   return ToNullableSingle((SqlMoney)  p);
				if (p is SqlSingle)  return ToNullableSingle((SqlSingle) p);
				if (p is SqlString)  return ToNullableSingle((SqlString) p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(Single?));
		}

		#endregion

		#region TimeSpan?

		// Simple Types
		//
		/// <summary>Converts the value from <c>DateTime</c> to an equivalent <c>TimeSpan?</c> value.</summary>
		public static TimeSpan? ToNullableTimeSpan(DateTime        p) { return p - DateTime.MinValue;                                                                  }
		/// <summary>Converts the value from <c>DateTimeOffset</c> to an equivalent <c>TimeSpan?</c> value.</summary>
		public static TimeSpan? ToNullableTimeSpan(DateTimeOffset  p) { return p - DateTimeOffset.MinValue;                                                            }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>TimeSpan?</c> value.</summary>
		public static TimeSpan? ToNullableTimeSpan(Double          p) { return TimeSpan.FromDays (p);                                                                  }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>TimeSpan?</c> value.</summary>
		public static TimeSpan? ToNullableTimeSpan(Int64           p) { return TimeSpan.FromTicks(p);                                                                  }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>TimeSpan?</c> value.</summary>
		public static TimeSpan? ToNullableTimeSpan(String          p) { return p == null? (TimeSpan?)null : TimeSpan.Parse(p);                                         }
		/// <summary>Converts the value from <c>TimeSpan</c> to an equivalent <c>TimeSpan?</c> value.</summary>
		public static TimeSpan? ToNullableTimeSpan(TimeSpan        p) { return p;                                                                                      }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>DateTime?</c> to an equivalent <c>TimeSpan?</c> value.</summary>
		public static TimeSpan? ToNullableTimeSpan(DateTime?       p) { return p.HasValue ? p.Value - DateTime.MinValue       : (TimeSpan?)null;                       }
		/// <summary>Converts the value from <c>DateTimeOffset?</c> to an equivalent <c>TimeSpan?</c> value.</summary>
		public static TimeSpan? ToNullableTimeSpan(DateTimeOffset? p) { return p.HasValue ? p.Value - DateTimeOffset.MinValue : (TimeSpan?)null;                       }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>TimeSpan?</c> value.</summary>
		public static TimeSpan? ToNullableTimeSpan(Double?         p) { return p.HasValue ? TimeSpan.FromDays (p.Value)            : (TimeSpan?)null;                  }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>TimeSpan?</c> value.</summary>
		public static TimeSpan? ToNullableTimeSpan(Int64?          p) { return p.HasValue ? TimeSpan.FromTicks(p.Value)            : (TimeSpan?)null;                  }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>TimeSpan?</c> value.</summary>
		public static TimeSpan? ToNullableTimeSpan(Binary          p) { return p == null || p.Length == 0? (TimeSpan?)null : TimeSpan.FromTicks(ToInt64(p.ToArray())); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>TimeSpan?</c> value.</summary>
		public static TimeSpan? ToNullableTimeSpan(Byte[]          p) { return p == null || p.Length == 0? (TimeSpan?)null : TimeSpan.FromTicks(ToInt64(p));           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlDateTime</c> to an equivalent <c>TimeSpan?</c> value.</summary>
		public static TimeSpan? ToNullableTimeSpan(SqlDateTime     p) { return p.IsNull   ? (TimeSpan?)null : p.Value - DateTime.MinValue;                             }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>TimeSpan?</c> value.</summary>
		public static TimeSpan? ToNullableTimeSpan(SqlDouble       p) { return p.IsNull   ? (TimeSpan?)null : TimeSpan.FromDays(p.Value);                              }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>TimeSpan?</c> value.</summary>
		public static TimeSpan? ToNullableTimeSpan(SqlInt64        p) { return p.IsNull   ? (TimeSpan?)null : TimeSpan.FromTicks(p.Value);                             }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>TimeSpan?</c> value.</summary>
		public static TimeSpan? ToNullableTimeSpan(SqlString       p) { return p.IsNull   ? (TimeSpan?)null : TimeSpan.Parse(p.Value);                                 }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>TimeSpan?</c> value.</summary>
		public static TimeSpan? ToNullableTimeSpan(object p)
		{
			if (p == null) return null;

			if (p is TimeSpan?) return (TimeSpan?)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull    : return null;
				case TypeCode.DateTime  : return ToNullableTimeSpan((DateTime) p);
				case TypeCode.Int64     : return ToNullableTimeSpan((Int64)    p);
				case TypeCode.Double    : return ToNullableTimeSpan((Double)   p);
				case TypeCode.String    : return ToNullableTimeSpan((String)   p);
			}

			// Simple Types
			//
			if (p is DateTimeOffset)  return ToNullableTimeSpan((DateTimeOffset) p);
			if (p is TimeSpan)        return ToNullableTimeSpan((TimeSpan)       p);

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is DateTime?)       return ToNullableTimeSpan((DateTime?)      p);
				if (p is DateTimeOffset?) return ToNullableTimeSpan((DateTimeOffset?)p);
				if (p is Double?)         return ToNullableTimeSpan((Double?)        p);
				if (p is Int64?)          return ToNullableTimeSpan((Int64?)         p);
			}

			// Other Types
			//
			if (p is Binary)          return ToNullableTimeSpan((Binary)         p);
			if (p is Byte[])          return ToNullableTimeSpan((Byte[])         p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlDateTime)     return ToNullableTimeSpan((SqlDateTime)    p);
				if (p is SqlDouble)       return ToNullableTimeSpan((SqlDouble)      p);
				if (p is SqlInt64)        return ToNullableTimeSpan((SqlInt64)       p);
				if (p is SqlString)       return ToNullableTimeSpan((SqlString)      p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(TimeSpan?));
		}

		#endregion

		#region UInt16?

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(Boolean    p) { return p ? (UInt16?)1 : (UInt16?)0;                                                        }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(Byte       p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(Char       p) { return checked((UInt16?)p);                                                                }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(Decimal    p) { return checked((UInt16?)p);                                                                }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(Double     p) { return checked((UInt16?)p);                                                                }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(Int16      p) { return checked((UInt16?)p);                                                                }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(Int32      p) { return checked((UInt16?)p);                                                                }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(Int64      p) { return checked((UInt16?)p);                                                                }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(SByte      p) { return checked((UInt16?)p);                                                                }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(Single     p) { return checked((UInt16?)p);                                                                }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(String     p) { return p == null? (UInt16?)null : UInt16.Parse(p);                                         }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(UInt16     p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(UInt32     p) { return checked((UInt16?)p);                                                                }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(UInt64     p) { return checked((UInt16?)p);                                                                }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(Boolean?   p) { return p.HasValue && p.Value ? (UInt16?)1: (UInt16?)0;                                     }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(Byte?      p) { return p.HasValue ? p.Value : (UInt16?)null;                                               }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(Char?      p) { return p.HasValue ? checked((UInt16?)p.Value) : (UInt16?)null;                             }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(Decimal?   p) { return p.HasValue ? checked((UInt16?)p.Value) : (UInt16?)null;                             }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(Double?    p) { return p.HasValue ? checked((UInt16?)p.Value) : (UInt16?)null;                             }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(Int16?     p) { return p.HasValue ? checked((UInt16?)p.Value) : (UInt16?)null;                             }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(Int32?     p) { return p.HasValue ? checked((UInt16?)p.Value) : (UInt16?)null;                             }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(Int64?     p) { return p.HasValue ? checked((UInt16?)p.Value) : (UInt16?)null;                             }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(SByte?     p) { return p.HasValue ? checked((UInt16?)p.Value) : (UInt16?)null;                             }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(Single?    p) { return p.HasValue ? checked((UInt16?)p.Value) : (UInt16?)null;                             }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(UInt32?    p) { return p.HasValue ? checked((UInt16?)p.Value) : (UInt16?)null;                             }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(UInt64?    p) { return p.HasValue ? checked((UInt16?)p.Value) : (UInt16?)null;                             }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(Binary     p) { return p == null || p.Length == 0 ? (UInt16?)null : BitConverter.ToUInt16(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(Byte[]     p) { return p == null || p.Length == 0 ? (UInt16?)null : BitConverter.ToUInt16(p, 0);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(SqlBoolean p) { return p.IsNull ? (UInt16?)null : ToUInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(SqlByte    p) { return p.IsNull ? (UInt16?)null : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(SqlDecimal p) { return p.IsNull ? (UInt16?)null : ToUInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(SqlDouble  p) { return p.IsNull ? (UInt16?)null : ToUInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(SqlInt16   p) { return p.IsNull ? (UInt16?)null : ToUInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(SqlInt32   p) { return p.IsNull ? (UInt16?)null : ToUInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(SqlInt64   p) { return p.IsNull ? (UInt16?)null : ToUInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(SqlMoney   p) { return p.IsNull ? (UInt16?)null : ToUInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(SqlSingle  p) { return p.IsNull ? (UInt16?)null : ToUInt16(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(SqlString  p) { return p.IsNull ? (UInt16?)null : ToUInt16(p.Value);                                       }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>UInt16?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt16? ToNullableUInt16(object p)
		{
			if (p == null) return null;

			if (p is UInt16?) return (UInt16?)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return null;
				case TypeCode.UInt16  : return ToNullableUInt16((UInt16) p);
				case TypeCode.Byte    : return ToNullableUInt16((Byte)   p);
				case TypeCode.SByte   : return ToNullableUInt16((SByte)  p);
				case TypeCode.Int16   : return ToNullableUInt16((Int16)  p);
				case TypeCode.Int32   : return ToNullableUInt16((Int32)  p);
				case TypeCode.Int64   : return ToNullableUInt16((Int64)  p);
				case TypeCode.UInt32  : return ToNullableUInt16((UInt32) p);
				case TypeCode.UInt64  : return ToNullableUInt16((UInt64) p);
				case TypeCode.Single  : return ToNullableUInt16((Single) p);
				case TypeCode.Double  : return ToNullableUInt16((Double) p);
				case TypeCode.Decimal : return ToNullableUInt16((Decimal)p);
				case TypeCode.Char    : return ToNullableUInt16((Char)   p);
				case TypeCode.String  : return ToNullableUInt16((String) p);
				case TypeCode.Boolean : return ToNullableUInt16((Boolean)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToNullableUInt16((Boolean?)  p);
				if (p is Byte?)      return ToNullableUInt16((Byte?)     p);
				if (p is Char?)      return ToNullableUInt16((Char?)     p);
				if (p is Decimal?)   return ToNullableUInt16((Decimal?)  p);
				if (p is Double?)    return ToNullableUInt16((Double?)   p);
				if (p is Int16?)     return ToNullableUInt16((Int16?)    p);
				if (p is Int32?)     return ToNullableUInt16((Int32?)    p);
				if (p is Int64?)     return ToNullableUInt16((Int64?)    p);
				if (p is SByte?)     return ToNullableUInt16((SByte?)    p);
				if (p is Single?)    return ToNullableUInt16((Single?)   p);
				if (p is UInt32?)    return ToNullableUInt16((UInt32?)   p);
				if (p is UInt64?)    return ToNullableUInt16((UInt64?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToNullableUInt16((Binary)    p);
			if (p is Byte[])     return ToNullableUInt16((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToNullableUInt16((SqlBoolean)p);
				if (p is SqlByte)    return ToNullableUInt16((SqlByte)   p);
				if (p is SqlDecimal) return ToNullableUInt16((SqlDecimal)p);
				if (p is SqlDouble)  return ToNullableUInt16((SqlDouble) p);
				if (p is SqlInt16)   return ToNullableUInt16((SqlInt16)  p);
				if (p is SqlInt32)   return ToNullableUInt16((SqlInt32)  p);
				if (p is SqlInt64)   return ToNullableUInt16((SqlInt64)  p);
				if (p is SqlMoney)   return ToNullableUInt16((SqlMoney)  p);
				if (p is SqlSingle)  return ToNullableUInt16((SqlSingle) p);
				if (p is SqlString)  return ToNullableUInt16((SqlString) p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(UInt16?));
		}

		#endregion

		#region UInt32?

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(Boolean    p) { return p ? (UInt32?)1 : (UInt32?)0;                                                        }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(Byte       p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(Char       p) { return checked((UInt32?)p);                                                                }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(Decimal    p) { return checked((UInt32?)p);                                                                }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(Double     p) { return checked((UInt32?)p);                                                                }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(Int16      p) { return checked((UInt32?)p);                                                                }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(Int32      p) { return checked((UInt32?)p);                                                                }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(Int64      p) { return checked((UInt32?)p);                                                                }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(SByte      p) { return checked((UInt32?)p);                                                                }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(Single     p) { return checked((UInt32?)p);                                                                }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(String     p) { return p == null? (UInt32?)null : UInt32.Parse(p);                                         }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(UInt16     p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(UInt32     p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(UInt64     p) { return checked((UInt32?)p);                                                                }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(Boolean?   p) { return p.HasValue && p.Value ? (UInt32?)1: (UInt32?)0;                                     }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(Byte?      p) { return p.HasValue ? p.Value : (UInt32?)null;                                               }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(Char?      p) { return p.HasValue ? checked((UInt32?)p.Value) : (UInt32?)null;                             }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(Decimal?   p) { return p.HasValue ? checked((UInt32?)p.Value) : (UInt32?)null;                             }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(Double?    p) { return p.HasValue ? checked((UInt32?)p.Value) : (UInt32?)null;                             }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(Int16?     p) { return p.HasValue ? checked((UInt32?)p.Value) : (UInt32?)null;                             }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(Int32?     p) { return p.HasValue ? checked((UInt32?)p.Value) : (UInt32?)null;                             }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(Int64?     p) { return p.HasValue ? checked((UInt32?)p.Value) : (UInt32?)null;                             }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(SByte?     p) { return p.HasValue ? checked((UInt32?)p.Value) : (UInt32?)null;                             }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(Single?    p) { return p.HasValue ? checked((UInt32?)p.Value) : (UInt32?)null;                             }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(UInt16?    p) { return p.HasValue ? p.Value : (UInt32?)null;                                               }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(UInt64?    p) { return p.HasValue ? checked((UInt32?)p.Value) : (UInt32?)null;                             }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(Binary     p) { return p == null || p.Length == 0 ? (UInt32?)null : BitConverter.ToUInt32(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(Byte[]     p) { return p == null || p.Length == 0 ? (UInt32?)null : BitConverter.ToUInt32(p, 0);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(SqlBoolean p) { return p.IsNull ? (UInt32?)null : ToUInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(SqlByte    p) { return p.IsNull ? (UInt32?)null : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(SqlDecimal p) { return p.IsNull ? (UInt32?)null : ToUInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(SqlDouble  p) { return p.IsNull ? (UInt32?)null : ToUInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(SqlInt16   p) { return p.IsNull ? (UInt32?)null : ToUInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(SqlInt32   p) { return p.IsNull ? (UInt32?)null : ToUInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(SqlInt64   p) { return p.IsNull ? (UInt32?)null : ToUInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(SqlMoney   p) { return p.IsNull ? (UInt32?)null : ToUInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(SqlSingle  p) { return p.IsNull ? (UInt32?)null : ToUInt32(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(SqlString  p) { return p.IsNull ? (UInt32?)null : ToUInt32(p.Value);                                       }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>UInt32?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt32? ToNullableUInt32(object p)
		{
			if (p == null) return null;

			if (p is UInt32?) return (UInt32?)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return null;
				case TypeCode.Byte    : return ToNullableUInt32((Byte)   p);
				case TypeCode.UInt16  : return ToNullableUInt32((UInt16) p);
				case TypeCode.UInt32  : return ToNullableUInt32((UInt32) p);
				case TypeCode.SByte   : return ToNullableUInt32((SByte)  p);
				case TypeCode.Int16   : return ToNullableUInt32((Int16)  p);
				case TypeCode.Int32   : return ToNullableUInt32((Int32)  p);
				case TypeCode.Int64   : return ToNullableUInt32((Int64)  p);
				case TypeCode.UInt64  : return ToNullableUInt32((UInt64) p);
				case TypeCode.Single  : return ToNullableUInt32((Single) p);
				case TypeCode.Double  : return ToNullableUInt32((Double) p);
				case TypeCode.Decimal : return ToNullableUInt32((Decimal)p);
				case TypeCode.Char    : return ToNullableUInt32((Char)   p);
				case TypeCode.String  : return ToNullableUInt32((String) p);
				case TypeCode.Boolean : return ToNullableUInt32((Boolean)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToNullableUInt32((Boolean?)  p);
				if (p is Byte?)      return ToNullableUInt32((Byte?)     p);
				if (p is Char?)      return ToNullableUInt32((Char?)     p);
				if (p is Decimal?)   return ToNullableUInt32((Decimal?)  p);
				if (p is Double?)    return ToNullableUInt32((Double?)   p);
				if (p is Int16?)     return ToNullableUInt32((Int16?)    p);
				if (p is Int32?)     return ToNullableUInt32((Int32?)    p);
				if (p is Int64?)     return ToNullableUInt32((Int64?)    p);
				if (p is SByte?)     return ToNullableUInt32((SByte?)    p);
				if (p is Single?)    return ToNullableUInt32((Single?)   p);
				if (p is UInt16?)    return ToNullableUInt32((UInt16?)   p);
				if (p is UInt64?)    return ToNullableUInt32((UInt64?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToNullableUInt32((Binary)    p);
			if (p is Byte[])     return ToNullableUInt32((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToNullableUInt32((SqlBoolean)p);
				if (p is SqlByte)    return ToNullableUInt32((SqlByte)   p);
				if (p is SqlDecimal) return ToNullableUInt32((SqlDecimal)p);
				if (p is SqlDouble)  return ToNullableUInt32((SqlDouble) p);
				if (p is SqlInt16)   return ToNullableUInt32((SqlInt16)  p);
				if (p is SqlInt32)   return ToNullableUInt32((SqlInt32)  p);
				if (p is SqlInt64)   return ToNullableUInt32((SqlInt64)  p);
				if (p is SqlMoney)   return ToNullableUInt32((SqlMoney)  p);
				if (p is SqlSingle)  return ToNullableUInt32((SqlSingle) p);
				if (p is SqlString)  return ToNullableUInt32((SqlString) p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(UInt32?));
		}

		#endregion

		#region UInt64?

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(Boolean    p) { return p ? (UInt64?)1 : (UInt64?)0;                                                        }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(Byte       p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(Char       p) { return checked((UInt64?)p);                                                                }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(Decimal    p) { return checked((UInt64?)p);                                                                }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(Double     p) { return checked((UInt64?)p);                                                                }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(Int16      p) { return checked((UInt64?)p);                                                                }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(Int32      p) { return checked((UInt64?)p);                                                                }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(Int64      p) { return checked((UInt64?)p);                                                                }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(SByte      p) { return checked((UInt64?)p);                                                                }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(Single     p) { return checked((UInt64?)p);                                                                }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(String     p) { return p == null? (UInt64?)null : UInt64.Parse(p);                                         }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(UInt16     p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(UInt32     p) { return p;                                                                                  }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(UInt64     p) { return p;                                                                                  }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(Boolean?   p) { return p.HasValue && p.Value ? (UInt64?)1: (UInt64?)0;                                     }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(Byte?      p) { return p.HasValue ? p.Value : (UInt64?)null;                                               }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(Char?      p) { return p.HasValue ? checked((UInt64?)p.Value) : (UInt64?)null;                             }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(Decimal?   p) { return p.HasValue ? checked((UInt64?)p.Value) : (UInt64?)null;                             }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(Double?    p) { return p.HasValue ? checked((UInt64?)p.Value) : (UInt64?)null;                             }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(Int16?     p) { return p.HasValue ? checked((UInt64?)p.Value) : (UInt64?)null;                             }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(Int32?     p) { return p.HasValue ? checked((UInt64?)p.Value) : (UInt64?)null;                             }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(Int64?     p) { return p.HasValue ? checked((UInt64?)p.Value) : (UInt64?)null;                             }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(SByte?     p) { return p.HasValue ? checked((UInt64?)p.Value) : (UInt64?)null;                             }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(Single?    p) { return p.HasValue ? checked((UInt64?)p.Value) : (UInt64?)null;                             }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(UInt16?    p) { return p.HasValue ? p.Value : (UInt64?)null;                                               }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(UInt32?    p) { return p.HasValue ? p.Value : (UInt64?)null;                                               }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(Binary     p) { return p == null || p.Length == 0 ? (UInt64?)null : BitConverter.ToUInt64(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(Byte[]     p) { return p == null || p.Length == 0 ? (UInt64?)null : BitConverter.ToUInt64(p, 0);           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(SqlBoolean p) { return p.IsNull ? (UInt64?)null : ToUInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(SqlByte    p) { return p.IsNull ? (UInt64?)null : p.Value;                                                 }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(SqlDecimal p) { return p.IsNull ? (UInt64?)null : ToUInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(SqlDouble  p) { return p.IsNull ? (UInt64?)null : ToUInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(SqlInt16   p) { return p.IsNull ? (UInt64?)null : ToUInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(SqlInt32   p) { return p.IsNull ? (UInt64?)null : ToUInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(SqlInt64   p) { return p.IsNull ? (UInt64?)null : ToUInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(SqlMoney   p) { return p.IsNull ? (UInt64?)null : ToUInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(SqlSingle  p) { return p.IsNull ? (UInt64?)null : ToUInt64(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(SqlString  p) { return p.IsNull ? (UInt64?)null : ToUInt64(p.Value);                                       }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>UInt64?</c> value.</summary>
		[CLSCompliant(false)]
		public static UInt64? ToNullableUInt64(object p)
		{
			if (p == null) return null;

			if (p is UInt64?) return (UInt64?)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return null;
				case TypeCode.Byte    : return ToNullableUInt64((Byte)   p);
				case TypeCode.UInt16  : return ToNullableUInt64((UInt16) p);
				case TypeCode.UInt32  : return ToNullableUInt64((UInt32) p);
				case TypeCode.UInt64  : return ToNullableUInt64((UInt64) p);
				case TypeCode.SByte   : return ToNullableUInt64((SByte)  p);
				case TypeCode.Int16   : return ToNullableUInt64((Int16)  p);
				case TypeCode.Int32   : return ToNullableUInt64((Int32)  p);
				case TypeCode.Int64   : return ToNullableUInt64((Int64)  p);
				case TypeCode.Single  : return ToNullableUInt64((Single) p);
				case TypeCode.Double  : return ToNullableUInt64((Double) p);
				case TypeCode.Decimal : return ToNullableUInt64((Decimal)p);
				case TypeCode.Char    : return ToNullableUInt64((Char)   p);
				case TypeCode.String  : return ToNullableUInt64((String) p);
				case TypeCode.Boolean : return ToNullableUInt64((Boolean)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToNullableUInt64((Boolean?)  p);
				if (p is Byte?)      return ToNullableUInt64((Byte?)     p);
				if (p is Char?)      return ToNullableUInt64((Char?)     p);
				if (p is Decimal?)   return ToNullableUInt64((Decimal?)  p);
				if (p is Double?)    return ToNullableUInt64((Double?)   p);
				if (p is Int16?)     return ToNullableUInt64((Int16?)    p);
				if (p is Int32?)     return ToNullableUInt64((Int32?)    p);
				if (p is Int64?)     return ToNullableUInt64((Int64?)    p);
				if (p is SByte?)     return ToNullableUInt64((SByte?)    p);
				if (p is Single?)    return ToNullableUInt64((Single?)   p);
				if (p is UInt16?)    return ToNullableUInt64((UInt16?)   p);
				if (p is UInt32?)    return ToNullableUInt64((UInt32?)   p);
			}

			// Other Types
			//
			if (p is Binary)     return ToNullableUInt64((Binary)    p);
			if (p is Byte[])     return ToNullableUInt64((Byte[])    p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToNullableUInt64((SqlBoolean)p);
				if (p is SqlByte)    return ToNullableUInt64((SqlByte)   p);
				if (p is SqlDecimal) return ToNullableUInt64((SqlDecimal)p);
				if (p is SqlDouble)  return ToNullableUInt64((SqlDouble) p);
				if (p is SqlInt16)   return ToNullableUInt64((SqlInt16)  p);
				if (p is SqlInt32)   return ToNullableUInt64((SqlInt32)  p);
				if (p is SqlInt64)   return ToNullableUInt64((SqlInt64)  p);
				if (p is SqlMoney)   return ToNullableUInt64((SqlMoney)  p);
				if (p is SqlSingle)  return ToNullableUInt64((SqlSingle) p);
				if (p is SqlString)  return ToNullableUInt64((SqlString) p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(UInt64?));
		}

		#endregion

		#endregion

		#region Sql Types

		#region SqlBinary

#if !SILVERLIGHT

		// Simple Types
		//
		/// <summary>Converts the value from <c>Guid</c> to an equivalent <c>SqlBinary</c> value.</summary>
		public static SqlBinary ToSqlBinary(Guid     p) { return p == Guid.Empty? SqlBinary.Null : new SqlGuid(p).ToSqlBinary();  }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Guid?</c> to an equivalent <c>SqlBinary</c> value.</summary>
		public static SqlBinary ToSqlBinary(Guid?    p) { return p.HasValue ? new SqlGuid(p.Value).ToSqlBinary(): SqlBinary.Null; }

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBytes</c> to an equivalent <c>SqlBinary</c> value.</summary>
		public static SqlBinary ToSqlBinary(SqlBytes p) { return p.ToSqlBinary();                                                 }
		/// <summary>Converts the value from <c>SqlGuid</c> to an equivalent <c>SqlBinary</c> value.</summary>
		public static SqlBinary ToSqlBinary(SqlGuid  p) { return p.ToSqlBinary();                                                 }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>SqlBinary</c> value.</summary>
		public static SqlBinary ToSqlBinary(Binary   p) { return p == null ?      SqlBinary.Null : p.ToArray();                   }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>SqlBinary</c> value.</summary>
		public static SqlBinary ToSqlBinary(Byte[]   p) { return p;                                                               }

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>SqlBinary</c> value.</summary>
		public static SqlBinary ToSqlBinary(object p)
		{
			if (p == null || p is DBNull) return SqlBinary.Null;

			if (p is SqlBinary) return (SqlBinary)p;

			// Simple Types
			//
			if (p is Guid)     return ToSqlBinary((Guid)    p);

			// Nullable Types
			//
			var type = p.GetType();

			if (type.IsGenericType)
			{
				if (p is Guid?)    return ToSqlBinary((Guid?)   p);
			}

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBytes) return ToSqlBinary((SqlBytes)p);
				if (p is SqlGuid)  return ToSqlBinary((SqlGuid) p);
			}

			// Other Types
			//
			if (p is Binary)   return ToSqlBinary((Binary)  p);
			if (p is Byte[])   return ToSqlBinary((Byte[])  p);

			throw CreateInvalidCastException(p.GetType(), typeof(SqlBinary));
		}

#endif

		#endregion

		#region SqlBoolean

#if !SILVERLIGHT

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(Boolean    p) { return p;                                                                                     }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(Byte       p) { return p != 0;                                                                                }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(Char       p) { return ToBoolean(p);                                                                          }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(Decimal    p) { return p != 0;                                                                                }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(Double     p) { return p != 0;                                                                                }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(Int16      p) { return p != 0;                                                                                }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(Int32      p) { return p != 0;                                                                                }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(Int64      p) { return p != 0;                                                                                }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlBoolean ToSqlBoolean(SByte      p) { return p != 0;                                                                                }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(Single     p) { return p != 0;                                                                                }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(String     p) { return p == null? SqlBoolean.Null : p.Length == 1 ? ToBoolean(p[0]) : Boolean.Parse(p);       }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlBoolean ToSqlBoolean(UInt16     p) { return p != 0;                                                                                }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlBoolean ToSqlBoolean(UInt32     p) { return p != 0;                                                                                }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlBoolean ToSqlBoolean(UInt64     p) { return p != 0;                                                                                }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(Boolean?   p) { return p.HasValue ? p.Value : SqlBoolean.Null;                                                }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(Byte?      p) { return p.HasValue ? p.Value != 0 : SqlBoolean.Null;                                           }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(Char?      p) { return p.HasValue && ToBoolean(p.Value);                                                      }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(Decimal?   p) { return p.HasValue ? p.Value != 0 : SqlBoolean.Null;                                           }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(Double?    p) { return p.HasValue ? p.Value != 0 : SqlBoolean.Null;                                           }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(Int16?     p) { return p.HasValue ? p.Value != 0 : SqlBoolean.Null;                                           }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(Int32?     p) { return p.HasValue ? p.Value != 0 : SqlBoolean.Null;                                           }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(Int64?     p) { return p.HasValue ? p.Value != 0 : SqlBoolean.Null;                                           }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlBoolean ToSqlBoolean(SByte?     p) { return p.HasValue ? p.Value != 0 : SqlBoolean.Null;                                           }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(Single?    p) { return p.HasValue ? p.Value != 0 : SqlBoolean.Null;                                           }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlBoolean ToSqlBoolean(UInt16?    p) { return p.HasValue ? p.Value != 0 : SqlBoolean.Null;                                           }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlBoolean ToSqlBoolean(UInt32?    p) { return p.HasValue ? p.Value != 0 : SqlBoolean.Null;                                           }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlBoolean ToSqlBoolean(UInt64?    p) { return p.HasValue ? p.Value != 0 : SqlBoolean.Null;                                           }

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(SqlByte    p) { return p.IsNull ? SqlBoolean.Null : ToBoolean(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(SqlDecimal p) { return p.IsNull ? SqlBoolean.Null : ToBoolean(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(SqlDouble  p) { return p.IsNull ? SqlBoolean.Null : ToBoolean(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(SqlInt16   p) { return p.IsNull ? SqlBoolean.Null : ToBoolean(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(SqlInt32   p) { return p.IsNull ? SqlBoolean.Null : ToBoolean(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(SqlInt64   p) { return p.IsNull ? SqlBoolean.Null : ToBoolean(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(SqlMoney   p) { return p.IsNull ? SqlBoolean.Null : ToBoolean(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(SqlSingle  p) { return p.IsNull ? SqlBoolean.Null : ToBoolean(p.Value);                                       }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(SqlString  p) { return p.IsNull ? SqlBoolean.Null : ToBoolean(p.Value);                                       }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(Binary     p) { return p == null || p.Length == 0 ? SqlBoolean.Null : BitConverter.ToBoolean(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(Byte[]     p) { return p == null || p.Length == 0 ? SqlBoolean.Null : BitConverter.ToBoolean(p, 0);           }

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>SqlBoolean</c> value.</summary>
		public static SqlBoolean ToSqlBoolean(object p)
		{
			if (p == null) return SqlBoolean.Null;

			if (p is SqlBoolean) return (SqlBoolean)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull     : return SqlBoolean.Null;
				case TypeCode.String     : return ToSqlBoolean((String)    p);
				case TypeCode.Boolean    : return ToSqlBoolean((Boolean)   p);
				case TypeCode.Char       : return ToSqlBoolean((Char)      p);
				case TypeCode.SByte      : return ToSqlBoolean((SByte)     p);
				case TypeCode.Int16      : return ToSqlBoolean((Int16)     p);
				case TypeCode.Int32      : return ToSqlBoolean((Int32)     p);
				case TypeCode.Int64      : return ToSqlBoolean((Int64)     p);
				case TypeCode.Byte       : return ToSqlBoolean((Byte)      p);
				case TypeCode.UInt16     : return ToSqlBoolean((UInt16)    p);
				case TypeCode.UInt32     : return ToSqlBoolean((UInt32)    p);
				case TypeCode.UInt64     : return ToSqlBoolean((UInt64)    p);
				case TypeCode.Single     : return ToSqlBoolean((Single)    p);
				case TypeCode.Double     : return ToSqlBoolean((Double)    p);
				case TypeCode.Decimal    : return ToSqlBoolean((Decimal)   p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToSqlBoolean((Boolean?)  p);
				if (p is Byte?)      return ToSqlBoolean((Byte?)     p);
				if (p is Char?)      return ToSqlBoolean((Char?)     p);
				if (p is Decimal?)   return ToSqlBoolean((Decimal?)  p);
				if (p is Double?)    return ToSqlBoolean((Double?)   p);
				if (p is Int16?)     return ToSqlBoolean((Int16?)    p);
				if (p is Int32?)     return ToSqlBoolean((Int32?)    p);
				if (p is Int64?)     return ToSqlBoolean((Int64?)    p);
				if (p is SByte?)     return ToSqlBoolean((SByte?)    p);
				if (p is Single?)    return ToSqlBoolean((Single?)   p);
				if (p is UInt16?)    return ToSqlBoolean((UInt16?)   p);
				if (p is UInt32?)    return ToSqlBoolean((UInt32?)   p);
				if (p is UInt64?)    return ToSqlBoolean((UInt64?)   p);
			}

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlByte)    return ToSqlBoolean((SqlByte)   p);
				if (p is SqlDecimal) return ToSqlBoolean((SqlDecimal)p);
				if (p is SqlDouble)  return ToSqlBoolean((SqlDouble) p);
				if (p is SqlInt16)   return ToSqlBoolean((SqlInt16)  p);
				if (p is SqlInt32)   return ToSqlBoolean((SqlInt32)  p);
				if (p is SqlInt64)   return ToSqlBoolean((SqlInt64)  p);
				if (p is SqlMoney)   return ToSqlBoolean((SqlMoney)  p);
				if (p is SqlSingle)  return ToSqlBoolean((SqlSingle) p);
				if (p is SqlString)  return ToSqlBoolean((SqlString) p);
			}

			// Other Types
			//
			if (p is Binary)     return ToSqlBoolean((Binary)    p);
			if (p is Byte[])     return ToSqlBoolean((Byte[])    p);

			throw CreateInvalidCastException(p.GetType(), typeof(SqlBoolean));
		}

#endif

		#endregion

		#region SqlByte

#if !SILVERLIGHT

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(Boolean    p) { return p ? (SqlByte)1 : (SqlByte)0;                                }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(Byte       p) { return p;                                                          }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(Char       p) { return checked((Byte)p);                                           }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(Decimal    p) { return checked((Byte)p);                                           }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(Double     p) { return checked((Byte)p);                                           }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(Int16      p) { return checked((Byte)p);                                           }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(Int32      p) { return checked((Byte)p);                                           }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(Int64      p) { return checked((Byte)p);                                           }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>SqlByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlByte ToSqlByte(SByte      p) { return checked((Byte)p);                                           }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(Single     p) { return checked((Byte)p);                                           }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(String     p) { return p == null? SqlByte.Null : Byte.Parse(p);                    }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>SqlByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlByte ToSqlByte(UInt16     p) { return checked((Byte)p);                                           }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>SqlByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlByte ToSqlByte(UInt32     p) { return checked((Byte)p);                                           }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>SqlByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlByte ToSqlByte(UInt64     p) { return checked((Byte)p);                                           }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(Boolean?   p) { return p.HasValue && p.Value ? (SqlByte)1: (SqlByte)0;             }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(Byte?      p) { return p.HasValue ? p.Value : SqlByte.Null;                        }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(Char?      p) { return p.HasValue ? checked((Byte)p.Value) : SqlByte.Null;         }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(Decimal?   p) { return p.HasValue ? checked((Byte)p.Value) : SqlByte.Null;         }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(Double?    p) { return p.HasValue ? checked((Byte)p.Value) : SqlByte.Null;         }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(Int16?     p) { return p.HasValue ? checked((Byte)p.Value) : SqlByte.Null;         }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(Int32?     p) { return p.HasValue ? checked((Byte)p.Value) : SqlByte.Null;         }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(Int64?     p) { return p.HasValue ? checked((Byte)p.Value) : SqlByte.Null;         }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>SqlByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlByte ToSqlByte(SByte?     p) { return p.HasValue ? checked((Byte)p.Value) : SqlByte.Null;         }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(Single?    p) { return p.HasValue ? checked((Byte)p.Value) : SqlByte.Null;         }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>SqlByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlByte ToSqlByte(UInt16?    p) { return p.HasValue ? checked((Byte)p.Value) : SqlByte.Null;         }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>SqlByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlByte ToSqlByte(UInt32?    p) { return p.HasValue ? checked((Byte)p.Value) : SqlByte.Null;         }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>SqlByte</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlByte ToSqlByte(UInt64?    p) { return p.HasValue ? checked((Byte)p.Value) : SqlByte.Null;         }

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(SqlBoolean p) { return p.ToSqlByte();                                              }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(SqlDecimal p) { return p.ToSqlByte();                                              }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(SqlDouble  p) { return p.ToSqlByte();                                              }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(SqlInt16   p) { return p.ToSqlByte();                                              }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(SqlInt32   p) { return p.ToSqlByte();                                              }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(SqlInt64   p) { return p.ToSqlByte();                                              }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(SqlMoney   p) { return p.ToSqlByte();                                              }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(SqlSingle  p) { return p.ToSqlByte();                                              }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(SqlString  p) { return p.ToSqlByte();                                              }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(Binary     p) { return p == null || p.Length == 0 ? SqlByte.Null : p.ToArray()[0]; }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(Byte[]     p) { return p == null || p.Length == 0 ? SqlByte.Null : p[0];           }

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>SqlByte</c> value.</summary>
		public static SqlByte ToSqlByte(object p)
		{
			if (p == null) return SqlByte.Null;

			if (p is SqlByte) return (SqlByte)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return SqlByte.Null;
				case TypeCode.Byte    : return ToSqlByte((Byte)   p);
				case TypeCode.SByte   : return ToSqlByte((SByte)  p);
				case TypeCode.Int16   : return ToSqlByte((Int16)  p);
				case TypeCode.Int32   : return ToSqlByte((Int32)  p);
				case TypeCode.Int64   : return ToSqlByte((Int64)  p);
				case TypeCode.UInt16  : return ToSqlByte((UInt16) p);
				case TypeCode.UInt32  : return ToSqlByte((UInt32) p);
				case TypeCode.UInt64  : return ToSqlByte((UInt64) p);
				case TypeCode.Single  : return ToSqlByte((Single) p);
				case TypeCode.Double  : return ToSqlByte((Double) p);
				case TypeCode.Decimal : return ToSqlByte((Decimal)p);
				case TypeCode.Char    : return ToSqlByte((Char)   p);
				case TypeCode.String  : return ToSqlByte((String) p);
				case TypeCode.Boolean : return ToSqlByte((Boolean)p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToSqlByte((Boolean?)  p);
				if (p is Byte?)      return ToSqlByte((Byte?)     p);
				if (p is Char?)      return ToSqlByte((Char?)     p);
				if (p is Decimal?)   return ToSqlByte((Decimal?)  p);
				if (p is Double?)    return ToSqlByte((Double?)   p);
				if (p is Int16?)     return ToSqlByte((Int16?)    p);
				if (p is Int32?)     return ToSqlByte((Int32?)    p);
				if (p is Int64?)     return ToSqlByte((Int64?)    p);
				if (p is SByte?)     return ToSqlByte((SByte?)    p);
				if (p is Single?)    return ToSqlByte((Single?)   p);
				if (p is UInt16?)    return ToSqlByte((UInt16?)   p);
				if (p is UInt32?)    return ToSqlByte((UInt32?)   p);
				if (p is UInt64?)    return ToSqlByte((UInt64?)   p);
			}

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToSqlByte((SqlBoolean)p);
				if (p is SqlDecimal) return ToSqlByte((SqlDecimal)p);
				if (p is SqlDouble)  return ToSqlByte((SqlDouble) p);
				if (p is SqlInt16)   return ToSqlByte((SqlInt16)  p);
				if (p is SqlInt32)   return ToSqlByte((SqlInt32)  p);
				if (p is SqlInt64)   return ToSqlByte((SqlInt64)  p);
				if (p is SqlMoney)   return ToSqlByte((SqlMoney)  p);
				if (p is SqlSingle)  return ToSqlByte((SqlSingle) p);
				if (p is SqlString)  return ToSqlByte((SqlString) p);
			}

			// Other Types
			//
			if (p is Binary)     return ToSqlByte((Binary)    p);
			if (p is Byte[])     return ToSqlByte((Byte[])    p);

			throw CreateInvalidCastException(p.GetType(), typeof(SqlByte));
		}

#endif

		#endregion

		#region SqlBytes

#if !SILVERLIGHT

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Boolean         p) { return new SqlBytes(ToByteArray(p));                                     }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Byte            p) { return new SqlBytes(ToByteArray(p));                                     }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Char            p) { return new SqlBytes(ToByteArray(p));                                     }
		/// <summary>Converts the value from <c>DateTime</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(DateTime        p) { return new SqlBytes(ToByteArray(p));                                     }
		/// <summary>Converts the value from <c>DateTimeOffset</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(DateTimeOffset  p) { return new SqlBytes(ToByteArray(p));                                     }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Double          p) { return new SqlBytes(ToByteArray(p));                                     }
		/// <summary>Converts the value from <c>Guid</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Guid            p) { return p == Guid.Empty ? SqlBytes.Null: new SqlBytes(p.ToByteArray());   }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Int16           p) { return new SqlBytes(ToByteArray(p));                                     }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Int32           p) { return new SqlBytes(ToByteArray(p));                                     }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Int64           p) { return new SqlBytes(ToByteArray(p));                                     }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>SqlBytes</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlBytes ToSqlBytes(SByte           p) { return new SqlBytes(ToByteArray(p));                                     }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Single          p) { return new SqlBytes(ToByteArray(p));                                     }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(String          p) { return p == null ? SqlBytes.Null : new SqlBytes(ToByteArray(p));         }
		/// <summary>Converts the value from <c>TimeSpan</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(TimeSpan        p) { return new SqlBytes(ToByteArray(p));                                     }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>SqlBytes</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlBytes ToSqlBytes(UInt16          p) { return new SqlBytes(ToByteArray(p));                                     }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>SqlBytes</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlBytes ToSqlBytes(UInt32          p) { return new SqlBytes(ToByteArray(p));                                     }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>SqlBytes</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlBytes ToSqlBytes(UInt64          p) { return new SqlBytes(ToByteArray(p));                                     }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Boolean?        p) { return p.HasValue ? ToSqlBytes(p.Value) : SqlBytes.Null;                 }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Byte?           p) { return p.HasValue ? ToSqlBytes(p.Value) : SqlBytes.Null;                 }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Char?           p) { return p.HasValue ? ToSqlBytes(p.Value) : SqlBytes.Null;                 }
		/// <summary>Converts the value from <c>DateTime?</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(DateTime?       p) { return p.HasValue ? ToSqlBytes(p.Value) : SqlBytes.Null;                 }
		/// <summary>Converts the value from <c>DateTimeOffset?</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(DateTimeOffset? p) { return p.HasValue ? ToSqlBytes(p.Value) : SqlBytes.Null;                 }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Decimal?        p) { return p.HasValue ? ToSqlBytes(p.Value) : SqlBytes.Null;                 }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Double?         p) { return p.HasValue ? ToSqlBytes(p.Value) : SqlBytes.Null;                 }
		/// <summary>Converts the value from <c>Guid?</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Guid?           p) { return p.HasValue ? new SqlBytes(p.Value.ToByteArray()) : SqlBytes.Null; }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Int16?          p) { return p.HasValue ? ToSqlBytes(p.Value) : SqlBytes.Null;                 }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Int32?          p) { return p.HasValue ? ToSqlBytes(p.Value) : SqlBytes.Null;                 }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Int64?          p) { return p.HasValue ? ToSqlBytes(p.Value) : SqlBytes.Null;                 }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>SqlBytes</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlBytes ToSqlBytes(SByte?          p) { return p.HasValue ? ToSqlBytes(p.Value) : SqlBytes.Null;                 }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Single?         p) { return p.HasValue ? ToSqlBytes(p.Value) : SqlBytes.Null;                 }
		/// <summary>Converts the value from <c>TimeSpan?</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(TimeSpan?       p) { return p.HasValue ? ToSqlBytes(p.Value) : SqlBytes.Null;                 }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>SqlBytes</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlBytes ToSqlBytes(UInt16?         p) { return p.HasValue ? ToSqlBytes(p.Value) : SqlBytes.Null;                 }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>SqlBytes</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlBytes ToSqlBytes(UInt32?         p) { return p.HasValue ? ToSqlBytes(p.Value) : SqlBytes.Null;                 }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>SqlBytes</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlBytes ToSqlBytes(UInt64?         p) { return p.HasValue ? ToSqlBytes(p.Value) : SqlBytes.Null;                 }

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBinary</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(SqlBinary       p) { return p.IsNull ? SqlBytes.Null : new SqlBytes(p);                       }
		/// <summary>Converts the value from <c>SqlGuid</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(SqlGuid         p) { return p.IsNull ? SqlBytes.Null : new SqlBytes(p.ToByteArray());         }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Binary          p) { return p == null ? SqlBytes.Null : new SqlBytes(p.ToArray());            }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Byte[]          p) { return p == null ? SqlBytes.Null : new SqlBytes(p);                      }
		/// <summary>Converts the value from <c>Stream</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(Stream          p) { return p == null ? SqlBytes.Null : new SqlBytes(p);                      }

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>SqlBytes</c> value.</summary>
		public static SqlBytes ToSqlBytes(object p)
		{
			if (p == null) return SqlBytes.Null;

			if (p is SqlBytes) return (SqlBytes)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull   : return SqlBytes.Null;
				case TypeCode.String   : return ToSqlBytes((String)  p);
				case TypeCode.Byte     : return ToSqlBytes((Byte)    p);
				case TypeCode.SByte    : return ToSqlBytes((SByte)   p);
				case TypeCode.DateTime : return ToSqlBytes((DateTime)p);
				case TypeCode.Int16    : return ToSqlBytes((Int16)   p);
				case TypeCode.Int32    : return ToSqlBytes((Int32)   p);
				case TypeCode.Int64    : return ToSqlBytes((Int64)   p);
				case TypeCode.UInt16   : return ToSqlBytes((UInt16)  p);
				case TypeCode.UInt32   : return ToSqlBytes((UInt32)  p);
				case TypeCode.UInt64   : return ToSqlBytes((UInt64)  p);
				case TypeCode.Single   : return ToSqlBytes((Single)  p);
				case TypeCode.Double   : return ToSqlBytes((Double)  p);
				case TypeCode.Boolean  : return ToSqlBytes((Boolean) p);
				case TypeCode.Char     : return ToSqlBytes((Char)    p);
			}

			// Simple Types
			//
			if (p is DateTimeOffset)  return ToSqlBytes((DateTimeOffset) p);
			if (p is Guid)            return ToSqlBytes((Guid)           p);
			if (p is TimeSpan)        return ToSqlBytes((TimeSpan)       p);

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)        return ToSqlBytes((Boolean?)       p);
				if (p is Byte?)           return ToSqlBytes((Byte?)          p);
				if (p is Char?)           return ToSqlBytes((Char?)          p);
				if (p is DateTime?)       return ToSqlBytes((DateTime?)      p);
				if (p is DateTimeOffset?) return ToSqlBytes((DateTimeOffset?)p);
				if (p is Decimal?)        return ToSqlBytes((Decimal?)       p);
				if (p is Double?)         return ToSqlBytes((Double?)        p);
				if (p is Guid?)           return ToSqlBytes((Guid?)          p);
				if (p is Int16?)          return ToSqlBytes((Int16?)         p);
				if (p is Int32?)          return ToSqlBytes((Int32?)         p);
				if (p is Int64?)          return ToSqlBytes((Int64?)         p);
				if (p is SByte?)          return ToSqlBytes((SByte?)         p);
				if (p is Single?)         return ToSqlBytes((Single?)        p);
				if (p is TimeSpan?)       return ToSqlBytes((TimeSpan?)      p);
				if (p is UInt16?)         return ToSqlBytes((UInt16?)        p);
				if (p is UInt32?)         return ToSqlBytes((UInt32?)        p);
				if (p is UInt64?)         return ToSqlBytes((UInt64?)        p);
			}

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBinary)       return ToSqlBytes((SqlBinary)      p);
				if (p is SqlGuid)         return ToSqlBytes((SqlGuid)        p);
			}

			// Other Types
			//
			if (p is Binary)          return ToSqlBytes((Binary)         p);
			if (p is Byte[])          return ToSqlBytes((Byte[])         p);
			if (p is Stream)          return ToSqlBytes((Stream)         p);

			throw CreateInvalidCastException(p.GetType(), typeof(SqlBytes));
		}

#endif

		#endregion

		#region SqlChars

#if !SILVERLIGHT

#endif

		#endregion

		#region SqlDateTime

#if !SILVERLIGHT

		// Simple Types
		//
		/// <summary>Converts the value from <c>DateTime</c> to an equivalent <c>SqlDateTime</c> value.</summary>
		public static SqlDateTime ToSqlDateTime(DateTime        p) { return p;                                                                                           }
		/// <summary>Converts the value from <c>DateTimeOffset</c> to an equivalent <c>SqlDateTime</c> value.</summary>
		public static SqlDateTime ToSqlDateTime(DateTimeOffset  p) { return p.LocalDateTime;                                                                             }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>SqlDateTime</c> value.</summary>
		public static SqlDateTime ToSqlDateTime(Double          p) { return DateTime.MinValue + TimeSpan.FromDays (p);                                                   }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>SqlDateTime</c> value.</summary>
		public static SqlDateTime ToSqlDateTime(Int64           p) { return DateTime.MinValue + TimeSpan.FromTicks(p);                                                   }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>SqlDateTime</c> value.</summary>
		public static SqlDateTime ToSqlDateTime(String          p) { return p == null ? SqlDateTime.Null : DateTime.Parse(p, null, DateTimeStyles.NoCurrentDateDefault); }
		/// <summary>Converts the value from <c>TimeSpan</c> to an equivalent <c>SqlDateTime</c> value.</summary>
		public static SqlDateTime ToSqlDateTime(TimeSpan        p) { return DateTime.MinValue + p;                                                                       }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>DateTime?</c> to an equivalent <c>SqlDateTime</c> value.</summary>
		public static SqlDateTime ToSqlDateTime(DateTime?       p) { return p.HasValue ? p.Value : SqlDateTime.Null;                                                     }
		/// <summary>Converts the value from <c>DateTimeOffset?</c> to an equivalent <c>SqlDateTime</c> value.</summary>
		public static SqlDateTime ToSqlDateTime(DateTimeOffset? p) { return p.HasValue ?                     p.Value.LocalDateTime : SqlDateTime.Null;                   }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>SqlDateTime</c> value.</summary>
		public static SqlDateTime ToSqlDateTime(Double?         p) { return p.HasValue ? DateTime.MinValue + TimeSpan.FromDays (p.Value): SqlDateTime.Null;              }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>SqlDateTime</c> value.</summary>
		public static SqlDateTime ToSqlDateTime(Int64?          p) { return p.HasValue ? DateTime.MinValue + TimeSpan.FromTicks(p.Value): SqlDateTime.Null;              }
		/// <summary>Converts the value from <c>TimeSpan?</c> to an equivalent <c>SqlDateTime</c> value.</summary>
		public static SqlDateTime ToSqlDateTime(TimeSpan?       p) { return p.HasValue ? DateTime.MinValue +                    p.Value : SqlDateTime.Null;              }

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>SqlDateTime</c> value.</summary>
		public static SqlDateTime ToSqlDateTime(SqlDouble       p) { return p.IsNull   ? SqlDateTime.Null : DateTime.MinValue + TimeSpan.FromDays (p.Value);             }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>SqlDateTime</c> value.</summary>
		public static SqlDateTime ToSqlDateTime(SqlInt64        p) { return p.IsNull   ? SqlDateTime.Null : DateTime.MinValue + TimeSpan.FromTicks(p.Value);             }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>SqlDateTime</c> value.</summary>
		public static SqlDateTime ToSqlDateTime(SqlString       p) { return p.IsNull   ? SqlDateTime.Null :                             ToDateTime(p.Value);             }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>SqlDateTime</c> value.</summary>
		public static SqlDateTime ToSqlDateTime(Binary          p) { return p == null || p.Length == 0 ? SqlDateTime.Null : DateTime.FromBinary(ToInt64(p.ToArray()));   }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>SqlDateTime</c> value.</summary>
		public static SqlDateTime ToSqlDateTime(Byte[]          p) { return p == null || p.Length == 0 ? SqlDateTime.Null : DateTime.FromBinary(ToInt64(p));             }

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>SqlDateTime</c> value.</summary>
		public static SqlDateTime ToSqlDateTime(object p)
		{
			if (p == null) return SqlDateTime.Null;

			if (p is SqlDateTime) return (SqlDateTime)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull      : return SqlDateTime.Null;
				case TypeCode.DateTime    : return ToSqlDateTime((DateTime)   p);
				case TypeCode.String      : return ToSqlDateTime((String)     p);
				case TypeCode.Int64       : return ToSqlDateTime((Int64)      p);
				case TypeCode.Double      : return ToSqlDateTime((Double)     p);
			}

			// Simple Types
			//
			if (p is DateTimeOffset)  return ToSqlDateTime((DateTimeOffset) p);
			if (p is TimeSpan)        return ToSqlDateTime((TimeSpan)       p);

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is DateTime?)       return ToSqlDateTime((DateTime?)      p);
				if (p is DateTimeOffset?) return ToSqlDateTime((DateTimeOffset?)p);
				if (p is Double?)         return ToSqlDateTime((Double?)        p);
				if (p is Int64?)          return ToSqlDateTime((Int64?)         p);
				if (p is TimeSpan?)       return ToSqlDateTime((TimeSpan?)      p);
			}

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlDouble)       return ToSqlDateTime((SqlDouble)      p);
				if (p is SqlInt64)        return ToSqlDateTime((SqlInt64)       p);
				if (p is SqlString)       return ToSqlDateTime((SqlString)      p);
			}

			// Other Types
			//
			if (p is Binary)          return ToSqlDateTime((Binary)         p);
			if (p is Byte[])          return ToSqlDateTime((Byte[])         p);

			throw CreateInvalidCastException(p.GetType(), typeof(SqlDateTime));
		}

#endif

		#endregion

		#region SqlDecimal

#if !SILVERLIGHT

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(Boolean    p) { return p ? (SqlDecimal)1 : (SqlDecimal)0;                           }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(Byte       p) { return p;                                                           }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(Char       p) { return p;                                                           }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(Decimal    p) { return p;                                                           }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(Double     p) { return checked((Decimal)p);                                         }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(Int16      p) { return p;                                                           }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(Int32      p) { return p;                                                           }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(Int64      p) { return p;                                                           }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlDecimal ToSqlDecimal(SByte      p) { return p;                                                           }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(Single     p) { return checked((Decimal)p);                                         }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(String     p) { return p == null? SqlDecimal.Null : Decimal.Parse(p);               }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlDecimal ToSqlDecimal(UInt16     p) { return p;                                                           }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlDecimal ToSqlDecimal(UInt32     p) { return p;                                                           }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlDecimal ToSqlDecimal(UInt64     p) { return p;                                                           }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(Boolean?   p) { return p.HasValue && p.Value ? (SqlDecimal)1: (SqlDecimal)0;        }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(Byte?      p) { return p.HasValue ? p.Value : SqlDecimal.Null;                      }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(Char?      p) { return p.HasValue ? p.Value : SqlDecimal.Null;                      }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(Decimal?   p) { return p.HasValue ? p.Value : SqlDecimal.Null;                      }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(Double?    p) { return p.HasValue ? checked((Decimal)p.Value) : SqlDecimal.Null;    }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(Int16?     p) { return p.HasValue ? p.Value : SqlDecimal.Null;                      }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(Int32?     p) { return p.HasValue ? p.Value : SqlDecimal.Null;                      }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(Int64?     p) { return p.HasValue ? p.Value : SqlDecimal.Null;                      }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlDecimal ToSqlDecimal(SByte?     p) { return p.HasValue ? p.Value : SqlDecimal.Null;                      }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(Single?    p) { return p.HasValue ? checked((Decimal)p.Value) : SqlDecimal.Null;    }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlDecimal ToSqlDecimal(UInt16?    p) { return p.HasValue ? p.Value : SqlDecimal.Null;                      }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlDecimal ToSqlDecimal(UInt32?    p) { return p.HasValue ? p.Value : SqlDecimal.Null;                      }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlDecimal ToSqlDecimal(UInt64?    p) { return p.HasValue ? p.Value : SqlDecimal.Null;                      }

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(SqlBoolean p) { return p.ToSqlDecimal();                                            }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(SqlByte    p) { return p.ToSqlDecimal();                                            }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(SqlDouble  p) { return p.ToSqlDecimal();                                            }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(SqlInt16   p) { return p.ToSqlDecimal();                                            }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(SqlInt32   p) { return p.ToSqlDecimal();                                            }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(SqlInt64   p) { return p.ToSqlDecimal();                                            }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(SqlMoney   p) { return p.ToSqlDecimal();                                            }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(SqlSingle  p) { return p.ToSqlDecimal();                                            }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(SqlString  p) { return p.ToSqlDecimal();                                            }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(Binary     p) { return p == null || p.Length == 0 ? SqlDecimal.Null : ToDecimal(p); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(Byte[]     p) { return p == null || p.Length == 0 ? SqlDecimal.Null : ToDecimal(p); }

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>SqlDecimal</c> value.</summary>
		public static SqlDecimal ToSqlDecimal(object p)
		{
			if (p == null) return SqlDecimal.Null;

			if (p is SqlDecimal) return (SqlDecimal)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull     : return SqlDecimal.Null;
				case TypeCode.SByte      : return ToSqlDecimal((SByte)     p);
				case TypeCode.Int16      : return ToSqlDecimal((Int16)     p);
				case TypeCode.Int32      : return ToSqlDecimal((Int32)     p);
				case TypeCode.Int64      : return ToSqlDecimal((Int64)     p);
				case TypeCode.Byte       : return ToSqlDecimal((Byte)      p);
				case TypeCode.UInt16     : return ToSqlDecimal((UInt16)    p);
				case TypeCode.UInt32     : return ToSqlDecimal((UInt32)    p);
				case TypeCode.Char       : return ToSqlDecimal((Char)      p);
				case TypeCode.UInt64     : return ToSqlDecimal((UInt64)    p);
				case TypeCode.Decimal    : return ToSqlDecimal((Decimal)   p);
				case TypeCode.Single     : return ToSqlDecimal((Single)    p);
				case TypeCode.Double     : return ToSqlDecimal((Double)    p);
				case TypeCode.String     : return ToSqlDecimal((String)    p);
				case TypeCode.Boolean    : return ToSqlDecimal((Boolean)   p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToSqlDecimal((Boolean?)  p);
				if (p is Byte?)      return ToSqlDecimal((Byte?)     p);
				if (p is Char?)      return ToSqlDecimal((Char?)     p);
				if (p is Decimal?)   return ToSqlDecimal((Decimal?)  p);
				if (p is Double?)    return ToSqlDecimal((Double?)   p);
				if (p is Int16?)     return ToSqlDecimal((Int16?)    p);
				if (p is Int32?)     return ToSqlDecimal((Int32?)    p);
				if (p is Int64?)     return ToSqlDecimal((Int64?)    p);
				if (p is SByte?)     return ToSqlDecimal((SByte?)    p);
				if (p is Single?)    return ToSqlDecimal((Single?)   p);
				if (p is UInt16?)    return ToSqlDecimal((UInt16?)   p);
				if (p is UInt32?)    return ToSqlDecimal((UInt32?)   p);
				if (p is UInt64?)    return ToSqlDecimal((UInt64?)   p);
			}

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToSqlDecimal((SqlBoolean)p);
				if (p is SqlByte)    return ToSqlDecimal((SqlByte)   p);
				if (p is SqlDouble)  return ToSqlDecimal((SqlDouble) p);
				if (p is SqlInt16)   return ToSqlDecimal((SqlInt16)  p);
				if (p is SqlInt32)   return ToSqlDecimal((SqlInt32)  p);
				if (p is SqlInt64)   return ToSqlDecimal((SqlInt64)  p);
				if (p is SqlMoney)   return ToSqlDecimal((SqlMoney)  p);
				if (p is SqlSingle)  return ToSqlDecimal((SqlSingle) p);
				if (p is SqlString)  return ToSqlDecimal((SqlString) p);
			}

			// Other Types
			//
			if (p is Binary)     return ToSqlDecimal((Binary)    p);
			if (p is Byte[])     return ToSqlDecimal((Byte[])    p);

			throw CreateInvalidCastException(p.GetType(), typeof(SqlDecimal));
		}

#endif

		#endregion

		#region SqlDouble

#if !SILVERLIGHT

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(Boolean         p) { return p ? (SqlDouble)1 : (SqlDouble)0;                                                     }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(Byte            p) { return p;                                                                                   }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(Char            p) { return p;                                                                                   }
		/// <summary>Converts the value from <c>DateTime</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(DateTime        p) { return (p - DateTime.MinValue).TotalDays;                                                   }
		/// <summary>Converts the value from <c>DateTimeOffset</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(DateTimeOffset  p) { return (p - DateTimeOffset.MinValue).TotalDays;                                             }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(Decimal         p) { return checked((Double)p);                                                                  }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(Double          p) { return p;                                                                                   }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(Int16           p) { return p;                                                                                   }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(Int32           p) { return p;                                                                                   }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(Int64           p) { return p;                                                                                   }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>SqlDouble</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlDouble ToSqlDouble(SByte           p) { return p;                                                                                   }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(Single          p) { return p;                                                                                   }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(String          p) { return p == null? SqlDouble.Null : Double.Parse(p);                                         }
		/// <summary>Converts the value from <c>TimeSpan</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(TimeSpan        p) { return p.TotalDays;                                                                         }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>SqlDouble</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlDouble ToSqlDouble(UInt16          p) { return p;                                                                                   }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>SqlDouble</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlDouble ToSqlDouble(UInt32          p) { return p;                                                                                   }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>SqlDouble</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlDouble ToSqlDouble(UInt64          p) { return p;                                                                                   }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(Boolean?        p) { return p.HasValue && p.Value ? (SqlDouble)1: (SqlDouble)0;                                  }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(Byte?           p) { return p.HasValue ? p.Value : SqlDouble.Null;                                               }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(Char?           p) { return p.HasValue ? p.Value : SqlDouble.Null;                                               }
		/// <summary>Converts the value from <c>DateTime?</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(DateTime?       p) { return p.HasValue ? (p.Value - DateTime.MinValue).TotalDays : SqlDouble.Null;               }
		/// <summary>Converts the value from <c>DateTimeOffset?</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(DateTimeOffset? p) { return p.HasValue ? (p.Value - DateTimeOffset.MinValue).TotalDays : SqlDouble.Null;         }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(Decimal?        p) { return p.HasValue ? checked((Double)p.Value) : SqlDouble.Null;                              }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(Double?         p) { return p.HasValue ? p.Value : SqlDouble.Null;                                               }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(Int16?          p) { return p.HasValue ? p.Value : SqlDouble.Null;                                               }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(Int32?          p) { return p.HasValue ? p.Value : SqlDouble.Null;                                               }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(Int64?          p) { return p.HasValue ? p.Value : SqlDouble.Null;                                               }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>SqlDouble</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlDouble ToSqlDouble(SByte?          p) { return p.HasValue ? p.Value : SqlDouble.Null;                                               }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(Single?         p) { return p.HasValue ? p.Value : SqlDouble.Null;                                               }
		/// <summary>Converts the value from <c>TimeSpan?</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(TimeSpan?       p) { return p.HasValue ? p.Value.TotalDays : SqlDouble.Null;                                     }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>SqlDouble</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlDouble ToSqlDouble(UInt16?         p) { return p.HasValue ? p.Value : SqlDouble.Null;                                               }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>SqlDouble</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlDouble ToSqlDouble(UInt32?         p) { return p.HasValue ? p.Value : SqlDouble.Null;                                               }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>SqlDouble</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlDouble ToSqlDouble(UInt64?         p) { return p.HasValue ? p.Value : SqlDouble.Null;                                               }

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(SqlBoolean      p) { return p.ToSqlDouble();                                                                     }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(SqlByte         p) { return p.ToSqlDouble();                                                                     }
		/// <summary>Converts the value from <c>SqlDateTime</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(SqlDateTime     p) { return p.IsNull? SqlDouble.Null: ToDouble(p.Value);                                         }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(SqlDecimal      p) { return p.ToSqlDouble();                                                                     }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(SqlInt16        p) { return p.ToSqlDouble();                                                                     }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(SqlInt32        p) { return p.ToSqlDouble();                                                                     }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(SqlInt64        p) { return p.ToSqlDouble();                                                                     }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(SqlMoney        p) { return p.ToSqlDouble();                                                                     }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(SqlSingle       p) { return p.ToSqlDouble();                                                                     }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(SqlString       p) { return p.ToSqlDouble();                                                                     }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(Binary          p) { return p == null || p.Length == 0 ? SqlDouble.Null : BitConverter.ToDouble(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(Byte[]          p) { return p == null || p.Length == 0 ? SqlDouble.Null : BitConverter.ToDouble(p, 0);           }

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>SqlDouble</c> value.</summary>
		public static SqlDouble ToSqlDouble(object p)
		{
			if (p == null) return SqlDouble.Null;

			if (p is SqlDouble) return (SqlDouble)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull    : return SqlDouble.Null;
				case TypeCode.DateTime  : return ToSqlDouble((DateTime) p);
				case TypeCode.SByte     : return ToSqlDouble((SByte)    p);
				case TypeCode.Int16     : return ToSqlDouble((Int16)    p);
				case TypeCode.Int32     : return ToSqlDouble((Int32)    p);
				case TypeCode.Int64     : return ToSqlDouble((Int64)    p);
				case TypeCode.Byte      : return ToSqlDouble((Byte)     p);
				case TypeCode.UInt16    : return ToSqlDouble((UInt16)   p);
				case TypeCode.UInt32    : return ToSqlDouble((UInt32)   p);
				case TypeCode.Char      : return ToSqlDouble((Char)     p);
				case TypeCode.UInt64    : return ToSqlDouble((UInt64)   p);
				case TypeCode.Single    : return ToSqlDouble((Single)   p);
				case TypeCode.Double    : return ToSqlDouble((Double)   p);
				case TypeCode.Decimal   : return ToSqlDouble((Decimal)  p);
				case TypeCode.String    : return ToSqlDouble((String)   p);
				case TypeCode.Boolean   : return ToSqlDouble((Boolean)  p);
			}

			// Simple Types
			//
			if (p is DateTimeOffset)  return ToSqlDouble((DateTimeOffset) p);
			if (p is TimeSpan)        return ToSqlDouble((TimeSpan)       p);

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)        return ToSqlDouble((Boolean?)       p);
				if (p is Byte?)           return ToSqlDouble((Byte?)          p);
				if (p is Char?)           return ToSqlDouble((Char?)          p);
				if (p is DateTime?)       return ToSqlDouble((DateTime?)      p);
				if (p is DateTimeOffset?) return ToSqlDouble((DateTimeOffset?)p);
				if (p is Decimal?)        return ToSqlDouble((Decimal?)       p);
				if (p is Double?)         return ToSqlDouble((Double?)        p);
				if (p is Int16?)          return ToSqlDouble((Int16?)         p);
				if (p is Int32?)          return ToSqlDouble((Int32?)         p);
				if (p is Int64?)          return ToSqlDouble((Int64?)         p);
				if (p is SByte?)          return ToSqlDouble((SByte?)         p);
				if (p is Single?)         return ToSqlDouble((Single?)        p);
				if (p is TimeSpan?)       return ToSqlDouble((TimeSpan?)      p);
				if (p is UInt16?)         return ToSqlDouble((UInt16?)        p);
				if (p is UInt32?)         return ToSqlDouble((UInt32?)        p);
				if (p is UInt64?)         return ToSqlDouble((UInt64?)        p);
			}

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean)      return ToSqlDouble((SqlBoolean)     p);
				if (p is SqlByte)         return ToSqlDouble((SqlByte)        p);
				if (p is SqlDateTime)     return ToSqlDouble((SqlDateTime)    p);
				if (p is SqlDecimal)      return ToSqlDouble((SqlDecimal)     p);
				if (p is SqlInt16)        return ToSqlDouble((SqlInt16)       p);
				if (p is SqlInt32)        return ToSqlDouble((SqlInt32)       p);
				if (p is SqlInt64)        return ToSqlDouble((SqlInt64)       p);
				if (p is SqlMoney)        return ToSqlDouble((SqlMoney)       p);
				if (p is SqlSingle)       return ToSqlDouble((SqlSingle)      p);
				if (p is SqlString)       return ToSqlDouble((SqlString)      p);
			}

			// Other Types
			//
			if (p is Binary)          return ToSqlDouble((Binary)         p);
			if (p is Byte[])          return ToSqlDouble((Byte[])         p);

			throw CreateInvalidCastException(p.GetType(), typeof(SqlDouble));
		}

#endif

		#endregion

		#region SqlGuid

#if !SILVERLIGHT

		// Simple Types
		//
		/// <summary>Converts the value from <c>Guid</c> to an equivalent <c>SqlGuid</c> value.</summary>
		public static SqlGuid ToSqlGuid(Guid      p) { return p;                                                }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>SqlGuid</c> value.</summary>
		public static SqlGuid ToSqlGuid(String    p) { return p == null ? SqlGuid.Null : new Guid(p);           }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Guid?</c> to an equivalent <c>SqlGuid</c> value.</summary>
		public static SqlGuid ToSqlGuid(Guid?     p) { return p.HasValue ? p.Value : SqlGuid.Null;              }

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBinary</c> to an equivalent <c>SqlGuid</c> value.</summary>
		public static SqlGuid ToSqlGuid(SqlBinary p) { return p.IsNull  ? SqlGuid.Null : p.ToSqlGuid().Value;   }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>SqlGuid</c> value.</summary>
		public static SqlGuid ToSqlGuid(SqlString p) { return p.IsNull  ? SqlGuid.Null : new Guid(p.Value);     }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>SqlGuid</c> value.</summary>
		public static SqlGuid ToSqlGuid(Binary    p) { return p == null ? SqlGuid.Null : new Guid(p.ToArray()); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>SqlGuid</c> value.</summary>
		public static SqlGuid ToSqlGuid(Byte[]    p) { return p == null ? SqlGuid.Null : new Guid(p);           }
		/// <summary>Converts the value from <c>Type</c> to an equivalent <c>SqlGuid</c> value.</summary>
		public static SqlGuid ToSqlGuid(Type      p) { return p == null ? SqlGuid.Null : p.GUID;                }

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>SqlGuid</c> value.</summary>
		public static SqlGuid ToSqlGuid(object p)
		{
			if (p == null) return SqlGuid.Null;

			if (p is SqlGuid) return (SqlGuid)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull  : return SqlGuid.Null;
				case TypeCode.String  : return ToSqlGuid((String) p);
			}

			// Simple Types
			//
			if (p is Guid)      return ToSqlGuid((Guid)     p);

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Guid?)     return ToSqlGuid((Guid?)    p);
			}

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBinary) return ToSqlGuid((SqlBinary)p);
				if (p is SqlString) return ToSqlGuid((SqlString)p);
			}

			// Other Types
			//
			if (p is Binary)    return ToSqlGuid((Binary)   p);
			if (p is Byte[])    return ToSqlGuid((Byte[])   p);
			if (p is Type)      return ToSqlGuid((Type)     p);

			throw CreateInvalidCastException(p.GetType(), typeof(SqlGuid));
		}

#endif

		#endregion

		#region SqlInt16

#if !SILVERLIGHT

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(Boolean    p) { return p ? (SqlInt16)1 : (SqlInt16)0;                                                     }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(Byte       p) { return p;                                                                                 }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(Char       p) { return checked((Int16)p);                                                                 }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(Decimal    p) { return checked((Int16)p);                                                                 }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(Double     p) { return checked((Int16)p);                                                                 }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(Int16      p) { return p;                                                                                 }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(Int32      p) { return checked((Int16)p);                                                                 }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(Int64      p) { return checked((Int16)p);                                                                 }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>SqlInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt16 ToSqlInt16(SByte      p) { return p;                                                                                 }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(Single     p) { return checked((Int16)p);                                                                 }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(String     p) { return p == null? SqlInt16.Null : Int16.Parse(p);                                         }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>SqlInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt16 ToSqlInt16(UInt16     p) { return checked((Int16)p);                                                                 }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>SqlInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt16 ToSqlInt16(UInt32     p) { return checked((Int16)p);                                                                 }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>SqlInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt16 ToSqlInt16(UInt64     p) { return checked((Int16)p);                                                                 }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(Boolean?   p) { return p.HasValue && p.Value ? (SqlInt16)1: (SqlInt16)0;                                  }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(Byte?      p) { return p.HasValue ? p.Value : SqlInt16.Null;                                              }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(Char?      p) { return p.HasValue ? checked((Int16)p.Value) : SqlInt16.Null;                              }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(Decimal?   p) { return p.HasValue ? checked((Int16)p.Value) : SqlInt16.Null;                              }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(Double?    p) { return p.HasValue ? checked((Int16)p.Value) : SqlInt16.Null;                              }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(Int16?     p) { return p.HasValue ? p.Value : SqlInt16.Null;                                              }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(Int32?     p) { return p.HasValue ? checked((Int16)p.Value) : SqlInt16.Null;                              }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(Int64?     p) { return p.HasValue ? checked((Int16)p.Value) : SqlInt16.Null;                              }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>SqlInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt16 ToSqlInt16(SByte?     p) { return p.HasValue ? p.Value : SqlInt16.Null;                                              }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(Single?    p) { return p.HasValue ? checked((Int16)p.Value) : SqlInt16.Null;                              }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>SqlInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt16 ToSqlInt16(UInt16?    p) { return p.HasValue ? checked((Int16)p.Value) : SqlInt16.Null;                              }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>SqlInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt16 ToSqlInt16(UInt32?    p) { return p.HasValue ? checked((Int16)p.Value) : SqlInt16.Null;                              }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>SqlInt16</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt16 ToSqlInt16(UInt64?    p) { return p.HasValue ? checked((Int16)p.Value) : SqlInt16.Null;                              }

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(SqlBoolean p) { return p.ToSqlInt16();                                                                    }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(SqlByte    p) { return p.ToSqlInt16();                                                                    }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(SqlDecimal p) { return p.ToSqlInt16();                                                                    }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(SqlDouble  p) { return p.ToSqlInt16();                                                                    }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(SqlInt32   p) { return p.ToSqlInt16();                                                                    }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(SqlInt64   p) { return p.ToSqlInt16();                                                                    }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(SqlMoney   p) { return p.ToSqlInt16();                                                                    }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(SqlSingle  p) { return p.ToSqlInt16();                                                                    }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(SqlString  p) { return p.ToSqlInt16();                                                                    }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(Binary     p) { return p == null || p.Length == 0 ? SqlInt16.Null : BitConverter.ToInt16(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(Byte[]     p) { return p == null || p.Length == 0 ? SqlInt16.Null : BitConverter.ToInt16(p, 0);           }

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(object p)
		{
			if (p == null) return SqlInt16.Null;

			if (p is SqlInt16) return (SqlInt16)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull   : return SqlInt16.Null;
				case TypeCode.SByte    : return ToSqlInt16((SByte)   p);
				case TypeCode.Int16    : return ToSqlInt16((Int16)   p);
				case TypeCode.Byte     : return ToSqlInt16((Byte)    p);
				case TypeCode.Int32    : return ToSqlInt16((Int32)   p);
				case TypeCode.Int64    : return ToSqlInt16((Int64)   p);
				case TypeCode.UInt16   : return ToSqlInt16((UInt16)  p);
				case TypeCode.UInt32   : return ToSqlInt16((UInt32)  p);
				case TypeCode.UInt64   : return ToSqlInt16((UInt64)  p);
				case TypeCode.Single   : return ToSqlInt16((Single)  p);
				case TypeCode.Double   : return ToSqlInt16((Double)  p);
				case TypeCode.Decimal  : return ToSqlInt16((Decimal) p);
				case TypeCode.Char     : return ToSqlInt16((Char)    p);
				case TypeCode.String   : return ToSqlInt16((String)  p);
				case TypeCode.Boolean  : return ToSqlInt16((Boolean) p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToSqlInt16((Boolean?)  p);
				if (p is Byte?)      return ToSqlInt16((Byte?)     p);
				if (p is Char?)      return ToSqlInt16((Char?)     p);
				if (p is Decimal?)   return ToSqlInt16((Decimal?)  p);
				if (p is Double?)    return ToSqlInt16((Double?)   p);
				if (p is Int16?)     return ToSqlInt16((Int16?)    p);
				if (p is Int32?)     return ToSqlInt16((Int32?)    p);
				if (p is Int64?)     return ToSqlInt16((Int64?)    p);
				if (p is SByte?)     return ToSqlInt16((SByte?)    p);
				if (p is Single?)    return ToSqlInt16((Single?)   p);
				if (p is UInt16?)    return ToSqlInt16((UInt16?)   p);
				if (p is UInt32?)    return ToSqlInt16((UInt32?)   p);
				if (p is UInt64?)    return ToSqlInt16((UInt64?)   p);
			}

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToSqlInt16((SqlBoolean)p);
				if (p is SqlByte)    return ToSqlInt16((SqlByte)   p);
				if (p is SqlDecimal) return ToSqlInt16((SqlDecimal)p);
				if (p is SqlDouble)  return ToSqlInt16((SqlDouble) p);
				if (p is SqlInt32)   return ToSqlInt16((SqlInt32)  p);
				if (p is SqlInt64)   return ToSqlInt16((SqlInt64)  p);
				if (p is SqlMoney)   return ToSqlInt16((SqlMoney)  p);
				if (p is SqlSingle)  return ToSqlInt16((SqlSingle) p);
				if (p is SqlString)  return ToSqlInt16((SqlString) p);
			}

			// Other Types
			//
			if (p is Binary)     return ToSqlInt16((Binary)    p);
			if (p is Byte[])     return ToSqlInt16((Byte[])    p);

			throw CreateInvalidCastException(p.GetType(), typeof(SqlInt16));
		}

#endif

		#endregion

		#region SqlInt32

#if !SILVERLIGHT

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(Boolean    p) { return p ? (SqlInt32)1 : (SqlInt32)0;                                                     }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(Byte       p) { return p;                                                                                 }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(Char       p) { return p;                                                                                 }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(Decimal    p) { return checked((Int32)p);                                                                 }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(Double     p) { return checked((Int32)p);                                                                 }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(Int16      p) { return p;                                                                                 }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(Int32      p) { return p;                                                                                 }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(Int64      p) { return checked((Int32)p);                                                                 }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>SqlInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt32 ToSqlInt32(SByte      p) { return p;                                                                                 }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(Single     p) { return checked((Int32)p);                                                                 }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(String     p) { return p == null? SqlInt32.Null : Int32.Parse(p);                                         }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>SqlInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt32 ToSqlInt32(UInt16     p) { return p;                                                                                 }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>SqlInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt32 ToSqlInt32(UInt32     p) { return checked((Int32)p);                                                                 }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>SqlInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt32 ToSqlInt32(UInt64     p) { return checked((Int32)p);                                                                 }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(Boolean?   p) { return p.HasValue && p.Value ? (SqlInt32)1: (SqlInt32)0;                                  }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(Byte?      p) { return p.HasValue ? p.Value : SqlInt32.Null;                                              }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(Char?      p) { return p.HasValue ? p.Value : SqlInt32.Null;                                              }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(Decimal?   p) { return p.HasValue ? checked((Int32)p.Value) : SqlInt32.Null;                              }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(Double?    p) { return p.HasValue ? checked((Int32)p.Value) : SqlInt32.Null;                              }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(Int16?     p) { return p.HasValue ? p.Value : SqlInt32.Null;                                              }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(Int32?     p) { return p.HasValue ? p.Value : SqlInt32.Null;                                              }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(Int64?     p) { return p.HasValue ? checked((Int32)p.Value) : SqlInt32.Null;                              }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>SqlInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt32 ToSqlInt32(SByte?     p) { return p.HasValue ? p.Value : SqlInt32.Null;                                              }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(Single?    p) { return p.HasValue ? checked((Int32)p.Value) : SqlInt32.Null;                              }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>SqlInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt32 ToSqlInt32(UInt16?    p) { return p.HasValue ? p.Value : SqlInt32.Null;                                              }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>SqlInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt32 ToSqlInt32(UInt32?    p) { return p.HasValue ? checked((Int32)p.Value) : SqlInt32.Null;                              }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>SqlInt32</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt32 ToSqlInt32(UInt64?    p) { return p.HasValue ? checked((Int32)p.Value) : SqlInt32.Null;                              }

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(SqlBoolean p) { return p.ToSqlInt32();                                                                    }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(SqlByte    p) { return p.ToSqlInt32();                                                                    }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(SqlDecimal p) { return p.ToSqlInt32();                                                                    }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(SqlDouble  p) { return p.ToSqlInt32();                                                                    }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(SqlInt16   p) { return p.ToSqlInt32();                                                                    }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(SqlInt64   p) { return p.ToSqlInt32();                                                                    }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(SqlMoney   p) { return p.ToSqlInt32();                                                                    }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(SqlSingle  p) { return p.ToSqlInt32();                                                                    }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(SqlString  p) { return p.ToSqlInt32();                                                                    }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(Binary     p) { return p == null || p.Length == 0 ? SqlInt32.Null : BitConverter.ToInt32(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(Byte[]     p) { return p == null || p.Length == 0 ? SqlInt32.Null : BitConverter.ToInt32(p, 0);           }

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>SqlInt32</c> value.</summary>
		public static SqlInt32 ToSqlInt32(object p)
		{
			if (p == null) return SqlInt32.Null;

			if (p is SqlInt32) return (SqlInt32)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull   : return SqlInt32.Null;
				case TypeCode.SByte    : return ToSqlInt32((SByte)   p);
				case TypeCode.Int16    : return ToSqlInt32((Int16)   p);
				case TypeCode.Int32    : return ToSqlInt32((Int32)   p);
				case TypeCode.Byte     : return ToSqlInt32((Byte)    p);
				case TypeCode.UInt16   : return ToSqlInt32((UInt16)  p);
				case TypeCode.Char     : return ToSqlInt32((Char)    p);
				case TypeCode.Int64    : return ToSqlInt32((Int64)   p);
				case TypeCode.UInt32   : return ToSqlInt32((UInt32)  p);
				case TypeCode.UInt64   : return ToSqlInt32((UInt64)  p);
				case TypeCode.Single   : return ToSqlInt32((Single)  p);
				case TypeCode.Double   : return ToSqlInt32((Double)  p);
				case TypeCode.Decimal  : return ToSqlInt32((Decimal) p);
				case TypeCode.String   : return ToSqlInt32((String)  p);
				case TypeCode.Boolean  : return ToSqlInt32((Boolean) p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToSqlInt32((Boolean?)  p);
				if (p is Byte?)      return ToSqlInt32((Byte?)     p);
				if (p is Char?)      return ToSqlInt32((Char?)     p);
				if (p is Decimal?)   return ToSqlInt32((Decimal?)  p);
				if (p is Double?)    return ToSqlInt32((Double?)   p);
				if (p is Int16?)     return ToSqlInt32((Int16?)    p);
				if (p is Int32?)     return ToSqlInt32((Int32?)    p);
				if (p is Int64?)     return ToSqlInt32((Int64?)    p);
				if (p is SByte?)     return ToSqlInt32((SByte?)    p);
				if (p is Single?)    return ToSqlInt32((Single?)   p);
				if (p is UInt16?)    return ToSqlInt32((UInt16?)   p);
				if (p is UInt32?)    return ToSqlInt32((UInt32?)   p);
				if (p is UInt64?)    return ToSqlInt32((UInt64?)   p);
			}

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToSqlInt32((SqlBoolean)p);
				if (p is SqlByte)    return ToSqlInt32((SqlByte)   p);
				if (p is SqlDecimal) return ToSqlInt32((SqlDecimal)p);
				if (p is SqlDouble)  return ToSqlInt32((SqlDouble) p);
				if (p is SqlInt16)   return ToSqlInt32((SqlInt16)  p);
				if (p is SqlInt64)   return ToSqlInt32((SqlInt64)  p);
				if (p is SqlMoney)   return ToSqlInt32((SqlMoney)  p);
				if (p is SqlSingle)  return ToSqlInt32((SqlSingle) p);
				if (p is SqlString)  return ToSqlInt32((SqlString) p);
			}

			// Other Types
			//
			if (p is Binary)     return ToSqlInt32((Binary)    p);
			if (p is Byte[])     return ToSqlInt32((Byte[])    p);

			throw CreateInvalidCastException(p.GetType(), typeof(SqlInt32));
		}

#endif

		#endregion

		#region SqlInt64

#if !SILVERLIGHT

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(Boolean         p) { return p ? (SqlInt64)1 : (SqlInt64)0;                                                     }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(Byte            p) { return p;                                                                                 }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(Char            p) { return p;                                                                                 }
		/// <summary>Converts the value from <c>DateTime</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(DateTime        p) { return (p - DateTime.MinValue).Ticks;                                                     }
		/// <summary>Converts the value from <c>DateTimeOffset</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(DateTimeOffset  p) { return (p - DateTime.MinValue).Ticks;                                                     }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(Decimal         p) { return checked((Int64)p);                                                                 }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(Double          p) { return checked((Int64)p);                                                                 }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(Int16           p) { return p;                                                                                 }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(Int32           p) { return p;                                                                                 }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(Int64           p) { return p;                                                                                 }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>SqlInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt64 ToSqlInt64(SByte           p) { return p;                                                                                 }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(Single          p) { return checked((Int64)p);                                                                 }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(String          p) { return p == null? SqlInt64.Null : Int64.Parse(p);                                         }
		/// <summary>Converts the value from <c>TimeSpan</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(TimeSpan        p) { return p.Ticks;                                                                           }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>SqlInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt64 ToSqlInt64(UInt16          p) { return p;                                                                                 }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>SqlInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt64 ToSqlInt64(UInt32          p) { return p;                                                                                 }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>SqlInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt64 ToSqlInt64(UInt64          p) { return checked((Int64)p);                                                                 }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(Boolean?        p) { return p.HasValue && p.Value ? (SqlInt64)1: (SqlInt64)0;                                  }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(Byte?           p) { return p.HasValue ? p.Value : SqlInt64.Null;                                              }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(Char?           p) { return p.HasValue ? p.Value : SqlInt64.Null;                                              }
		/// <summary>Converts the value from <c>DateTime?</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(DateTime?       p) { return p.HasValue ? (p.Value - DateTime.MinValue).Ticks : 0;                              }
		/// <summary>Converts the value from <c>DateTimeOffset?</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(DateTimeOffset? p) { return p.HasValue ? (p.Value - DateTime.MinValue).Ticks : 0;                              }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(Decimal?        p) { return p.HasValue ? checked((Int64)p.Value) : SqlInt64.Null;                              }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(Double?         p) { return p.HasValue ? checked((Int64)p.Value) : SqlInt64.Null;                              }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(Int16?          p) { return p.HasValue ? p.Value : SqlInt64.Null;                                              }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(Int32?          p) { return p.HasValue ? p.Value : SqlInt64.Null;                                              }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(Int64?          p) { return p.HasValue ? p.Value : SqlInt64.Null;                                              }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>SqlInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt64 ToSqlInt64(SByte?          p) { return p.HasValue ? p.Value : SqlInt64.Null;                                              }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(Single?         p) { return p.HasValue ? checked((Int64)p.Value) : SqlInt64.Null;                              }
		/// <summary>Converts the value from <c>TimeSpan?</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(TimeSpan?       p) { return p.HasValue ? p.Value.Ticks : 0;                                                    }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>SqlInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt64 ToSqlInt64(UInt16?         p) { return p.HasValue ? p.Value : SqlInt64.Null;                                              }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>SqlInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt64 ToSqlInt64(UInt32?         p) { return p.HasValue ? p.Value : SqlInt64.Null;                                              }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>SqlInt64</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlInt64 ToSqlInt64(UInt64?         p) { return p.HasValue ? checked((Int64)p.Value) : SqlInt64.Null;                              }

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(SqlBoolean      p) { return p.ToSqlInt64();                                                                    }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(SqlByte         p) { return p.ToSqlInt64();                                                                    }
		/// <summary>Converts the value from <c>SqlDateTime</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(SqlDateTime     p) { return p.IsNull? SqlInt64.Null: ToInt64(p.Value);                                         }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(SqlDecimal      p) { return p.ToSqlInt64();                                                                    }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(SqlDouble       p) { return p.ToSqlInt64();                                                                    }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(SqlInt16        p) { return p.ToSqlInt64();                                                                    }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(SqlInt32        p) { return p.ToSqlInt64();                                                                    }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(SqlMoney        p) { return p.ToSqlInt64();                                                                    }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(SqlSingle       p) { return p.ToSqlInt64();                                                                    }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(SqlString       p) { return p.ToSqlInt64();                                                                    }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(Binary          p) { return p == null || p.Length == 0 ? SqlInt64.Null : BitConverter.ToInt64(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(Byte[]          p) { return p == null || p.Length == 0 ? SqlInt64.Null : BitConverter.ToInt64(p, 0);           }

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>SqlInt64</c> value.</summary>
		public static SqlInt64 ToSqlInt64(object p)
		{
			if (p == null) return SqlInt64.Null;

			if (p is SqlInt64) return (SqlInt64)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull   : return SqlInt64.Null;
				case TypeCode.DateTime : return ToSqlInt64((DateTime)p);
				case TypeCode.SByte    : return ToSqlInt64((SByte)   p);
				case TypeCode.Int16    : return ToSqlInt64((Int16)   p);
				case TypeCode.Int32    : return ToSqlInt64((Int32)   p);
				case TypeCode.Int64    : return ToSqlInt64((Int64)   p);
				case TypeCode.Byte     : return ToSqlInt64((Byte)    p);
				case TypeCode.UInt16   : return ToSqlInt64((UInt16)  p);
				case TypeCode.UInt32   : return ToSqlInt64((UInt32)  p);
				case TypeCode.Char     : return ToSqlInt64((Char)    p);
				case TypeCode.UInt64   : return ToSqlInt64((UInt64)  p);
				case TypeCode.Single   : return ToSqlInt64((Single)  p);
				case TypeCode.Double   : return ToSqlInt64((Double)  p);
				case TypeCode.Decimal  : return ToSqlInt64((Decimal) p);
				case TypeCode.String   : return ToSqlInt64((String)  p);
				case TypeCode.Boolean  : return ToSqlInt64((Boolean) p);
			}

			// Simple Types
			//
			if (p is DateTimeOffset)  return ToSqlInt64((DateTimeOffset) p);
			if (p is TimeSpan)        return ToSqlInt64((TimeSpan)       p);

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)        return ToSqlInt64((Boolean?)       p);
				if (p is Byte?)           return ToSqlInt64((Byte?)          p);
				if (p is Char?)           return ToSqlInt64((Char?)          p);
				if (p is DateTime?)       return ToSqlInt64((DateTime?)      p);
				if (p is DateTimeOffset?) return ToSqlInt64((DateTimeOffset?)p);
				if (p is Decimal?)        return ToSqlInt64((Decimal?)       p);
				if (p is Double?)         return ToSqlInt64((Double?)        p);
				if (p is Int16?)          return ToSqlInt64((Int16?)         p);
				if (p is Int32?)          return ToSqlInt64((Int32?)         p);
				if (p is Int64?)          return ToSqlInt64((Int64?)         p);
				if (p is SByte?)          return ToSqlInt64((SByte?)         p);
				if (p is Single?)         return ToSqlInt64((Single?)        p);
				if (p is TimeSpan?)       return ToSqlInt64((TimeSpan?)      p);
				if (p is UInt16?)         return ToSqlInt64((UInt16?)        p);
				if (p is UInt32?)         return ToSqlInt64((UInt32?)        p);
				if (p is UInt64?)         return ToSqlInt64((UInt64?)        p);
			}

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean)      return ToSqlInt64((SqlBoolean)     p);
				if (p is SqlByte)         return ToSqlInt64((SqlByte)        p);
				if (p is SqlDateTime)     return ToSqlInt64((SqlDateTime)    p);
				if (p is SqlDecimal)      return ToSqlInt64((SqlDecimal)     p);
				if (p is SqlDouble)       return ToSqlInt64((SqlDouble)      p);
				if (p is SqlInt16)        return ToSqlInt64((SqlInt16)       p);
				if (p is SqlInt32)        return ToSqlInt64((SqlInt32)       p);
				if (p is SqlMoney)        return ToSqlInt64((SqlMoney)       p);
				if (p is SqlSingle)       return ToSqlInt64((SqlSingle)      p);
				if (p is SqlString)       return ToSqlInt64((SqlString)      p);
			}

			// Other Types
			//
			if (p is Binary)          return ToSqlInt64((Binary)         p);
			if (p is Byte[])          return ToSqlInt64((Byte[])         p);

			throw CreateInvalidCastException(p.GetType(), typeof(SqlInt64));
		}

#endif

		#endregion

		#region SqlMoney

#if !SILVERLIGHT

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(Boolean    p) { return p ? (SqlMoney)1 : (SqlMoney)0;                             }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(Byte       p) { return p;                                                         }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(Char       p) { return p;                                                         }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(Decimal    p) { return p;                                                         }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(Double     p) { return checked((Decimal)p);                                       }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(Int16      p) { return p;                                                         }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(Int32      p) { return p;                                                         }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(Int64      p) { return p;                                                         }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>SqlMoney</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlMoney ToSqlMoney(SByte      p) { return p;                                                         }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(Single     p) { return checked((Decimal)p);                                       }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(String     p) { return p == null? SqlMoney.Null : Decimal.Parse(p);               }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>SqlMoney</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlMoney ToSqlMoney(UInt16     p) { return p;                                                         }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>SqlMoney</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlMoney ToSqlMoney(UInt32     p) { return p;                                                         }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>SqlMoney</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlMoney ToSqlMoney(UInt64     p) { return p;                                                         }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(Boolean?   p) { return p.HasValue && p.Value ? (SqlMoney)1: (SqlMoney)0;          }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(Byte?      p) { return p.HasValue ? p.Value : SqlMoney.Null;                      }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(Char?      p) { return p.HasValue ? p.Value : SqlMoney.Null;                      }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(Decimal?   p) { return p.HasValue ? p.Value : SqlMoney.Null;                      }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(Double?    p) { return p.HasValue ? checked((Decimal)p.Value) : SqlMoney.Null;    }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(Int16?     p) { return p.HasValue ? p.Value : SqlMoney.Null;                      }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(Int32?     p) { return p.HasValue ? p.Value : SqlMoney.Null;                      }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(Int64?     p) { return p.HasValue ? p.Value : SqlMoney.Null;                      }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>SqlMoney</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlMoney ToSqlMoney(SByte?     p) { return p.HasValue ? p.Value : SqlMoney.Null;                      }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(Single?    p) { return p.HasValue ? checked((Decimal)p.Value) : SqlMoney.Null;    }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>SqlMoney</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlMoney ToSqlMoney(UInt16?    p) { return p.HasValue ? p.Value : SqlMoney.Null;                      }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>SqlMoney</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlMoney ToSqlMoney(UInt32?    p) { return p.HasValue ? p.Value : SqlMoney.Null;                      }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>SqlMoney</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlMoney ToSqlMoney(UInt64?    p) { return p.HasValue ? p.Value : SqlMoney.Null;                      }

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(SqlBoolean p) { return p.ToSqlMoney();                                            }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(SqlByte    p) { return p.ToSqlMoney();                                            }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(SqlDecimal p) { return p.ToSqlMoney();                                            }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(SqlDouble  p) { return p.ToSqlMoney();                                            }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(SqlInt16   p) { return p.ToSqlMoney();                                            }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(SqlInt32   p) { return p.ToSqlMoney();                                            }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(SqlInt64   p) { return p.ToSqlMoney();                                            }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(SqlSingle  p) { return p.ToSqlMoney();                                            }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(SqlString  p) { return p.ToSqlMoney();                                            }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(Binary     p) { return p == null || p.Length == 0 ? SqlMoney.Null : ToDecimal(p); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(Byte[]     p) { return p == null || p.Length == 0 ? SqlMoney.Null : ToDecimal(p); }

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>SqlMoney</c> value.</summary>
		public static SqlMoney ToSqlMoney(object p)
		{
			if (p == null) return SqlMoney.Null;

			if (p is SqlMoney) return (SqlMoney)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull   : return SqlMoney.Null;
				case TypeCode.SByte    : return ToSqlMoney((SByte)   p);
				case TypeCode.Int16    : return ToSqlMoney((Int16)   p);
				case TypeCode.Int32    : return ToSqlMoney((Int32)   p);
				case TypeCode.Int64    : return ToSqlMoney((Int64)   p);
				case TypeCode.Byte     : return ToSqlMoney((Byte)    p);
				case TypeCode.UInt16   : return ToSqlMoney((UInt16)  p);
				case TypeCode.UInt32   : return ToSqlMoney((UInt32)  p);
				case TypeCode.Char     : return ToSqlMoney((Char)    p);
				case TypeCode.UInt64   : return ToSqlMoney((UInt64)  p);
				case TypeCode.Decimal  : return ToSqlMoney((Decimal) p);
				case TypeCode.Single   : return ToSqlMoney((Single)  p);
				case TypeCode.Double   : return ToSqlMoney((Double)  p);
				case TypeCode.String   : return ToSqlMoney((String)  p);
				case TypeCode.Boolean  : return ToSqlMoney((Boolean) p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToSqlMoney((Boolean?)  p);
				if (p is Byte?)      return ToSqlMoney((Byte?)     p);
				if (p is Char?)      return ToSqlMoney((Char?)     p);
				if (p is Decimal?)   return ToSqlMoney((Decimal?)  p);
				if (p is Double?)    return ToSqlMoney((Double?)   p);
				if (p is Int16?)     return ToSqlMoney((Int16?)    p);
				if (p is Int32?)     return ToSqlMoney((Int32?)    p);
				if (p is Int64?)     return ToSqlMoney((Int64?)    p);
				if (p is SByte?)     return ToSqlMoney((SByte?)    p);
				if (p is Single?)    return ToSqlMoney((Single?)   p);
				if (p is UInt16?)    return ToSqlMoney((UInt16?)   p);
				if (p is UInt32?)    return ToSqlMoney((UInt32?)   p);
				if (p is UInt64?)    return ToSqlMoney((UInt64?)   p);
			}

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToSqlMoney((SqlBoolean)p);
				if (p is SqlByte)    return ToSqlMoney((SqlByte)   p);
				if (p is SqlDecimal) return ToSqlMoney((SqlDecimal)p);
				if (p is SqlDouble)  return ToSqlMoney((SqlDouble) p);
				if (p is SqlInt16)   return ToSqlMoney((SqlInt16)  p);
				if (p is SqlInt32)   return ToSqlMoney((SqlInt32)  p);
				if (p is SqlInt64)   return ToSqlMoney((SqlInt64)  p);
				if (p is SqlSingle)  return ToSqlMoney((SqlSingle) p);
				if (p is SqlString)  return ToSqlMoney((SqlString) p);
			}

			// Other Types
			//
			if (p is Binary)     return ToSqlMoney((Binary)    p);
			if (p is Byte[])     return ToSqlMoney((Byte[])    p);

			throw CreateInvalidCastException(p.GetType(), typeof(SqlMoney));
		}

#endif

		#endregion

		#region SqlSingle

#if !SILVERLIGHT

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(Boolean    p) { return p ? (SqlSingle)1 : (SqlSingle)0;                                                     }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(Byte       p) { return p;                                                                                   }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(Char       p) { return p;                                                                                   }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(Decimal    p) { return checked((Single)p);                                                                  }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(Double     p) { return checked((Single)p);                                                                  }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(Int16      p) { return p;                                                                                   }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(Int32      p) { return p;                                                                                   }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(Int64      p) { return p;                                                                                   }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>SqlSingle</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlSingle ToSqlSingle(SByte      p) { return p;                                                                                   }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(Single     p) { return p;                                                                                   }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(String     p) { return p == null? SqlSingle.Null : Single.Parse(p);                                         }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>SqlSingle</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlSingle ToSqlSingle(UInt16     p) { return p;                                                                                   }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>SqlSingle</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlSingle ToSqlSingle(UInt32     p) { return p;                                                                                   }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>SqlSingle</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlSingle ToSqlSingle(UInt64     p) { return p;                                                                                   }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(Boolean?   p) { return p.HasValue && p.Value ? (SqlSingle)1: (SqlSingle)0;                                  }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(Byte?      p) { return p.HasValue ? p.Value : SqlSingle.Null;                                               }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(Char?      p) { return p.HasValue ? p.Value : SqlSingle.Null;                                               }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(Decimal?   p) { return p.HasValue ? checked((Single)p.Value) : SqlSingle.Null;                              }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(Double?    p) { return p.HasValue ? checked((Single)p.Value) : SqlSingle.Null;                              }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(Int16?     p) { return p.HasValue ? p.Value : SqlSingle.Null;                                               }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(Int32?     p) { return p.HasValue ? p.Value : SqlSingle.Null;                                               }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(Int64?     p) { return p.HasValue ? p.Value : SqlSingle.Null;                                               }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>SqlSingle</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlSingle ToSqlSingle(SByte?     p) { return p.HasValue ? p.Value : SqlSingle.Null;                                               }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(Single?    p) { return p.HasValue ? p.Value : SqlSingle.Null;                                               }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>SqlSingle</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlSingle ToSqlSingle(UInt16?    p) { return p.HasValue ? p.Value : SqlSingle.Null;                                               }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>SqlSingle</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlSingle ToSqlSingle(UInt32?    p) { return p.HasValue ? p.Value : SqlSingle.Null;                                               }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>SqlSingle</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlSingle ToSqlSingle(UInt64?    p) { return p.HasValue ? p.Value : SqlSingle.Null;                                               }

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(SqlBoolean p) { return p.ToSqlSingle();                                                                     }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(SqlByte    p) { return p.ToSqlSingle();                                                                     }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(SqlDecimal p) { return p.ToSqlSingle();                                                                     }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(SqlDouble  p) { return p.ToSqlSingle();                                                                     }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(SqlInt16   p) { return p.ToSqlSingle();                                                                     }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(SqlInt32   p) { return p.ToSqlSingle();                                                                     }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(SqlInt64   p) { return p.ToSqlSingle();                                                                     }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(SqlMoney   p) { return p.ToSqlSingle();                                                                     }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(SqlString  p) { return p.ToSqlSingle();                                                                     }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(Binary     p) { return p == null || p.Length == 0 ? SqlSingle.Null : BitConverter.ToSingle(p.ToArray(), 0); }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(Byte[]     p) { return p == null || p.Length == 0 ? SqlSingle.Null : BitConverter.ToSingle(p, 0);           }

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>SqlSingle</c> value.</summary>
		public static SqlSingle ToSqlSingle(object p)
		{
			if (p == null) return SqlSingle.Null;

			if (p is SqlSingle) return (SqlSingle)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull    : return SqlSingle.Null;
				case TypeCode.SByte     : return ToSqlSingle((SByte)    p);
				case TypeCode.Int16     : return ToSqlSingle((Int16)    p);
				case TypeCode.Int32     : return ToSqlSingle((Int32)    p);
				case TypeCode.Int64     : return ToSqlSingle((Int64)    p);
				case TypeCode.Byte      : return ToSqlSingle((Byte)     p);
				case TypeCode.UInt16    : return ToSqlSingle((UInt16)   p);
				case TypeCode.UInt32    : return ToSqlSingle((UInt32)   p);
				case TypeCode.Char      : return ToSqlSingle((Char)     p);
				case TypeCode.UInt64    : return ToSqlSingle((UInt64)   p);
				case TypeCode.Single    : return ToSqlSingle((Single)   p);
				case TypeCode.Double    : return ToSqlSingle((Double)   p);
				case TypeCode.Decimal   : return ToSqlSingle((Decimal)  p);
				case TypeCode.String    : return ToSqlSingle((String)   p);
				case TypeCode.Boolean   : return ToSqlSingle((Boolean)  p);
			}

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)   return ToSqlSingle((Boolean?)  p);
				if (p is Byte?)      return ToSqlSingle((Byte?)     p);
				if (p is Char?)      return ToSqlSingle((Char?)     p);
				if (p is Decimal?)   return ToSqlSingle((Decimal?)  p);
				if (p is Double?)    return ToSqlSingle((Double?)   p);
				if (p is Int16?)     return ToSqlSingle((Int16?)    p);
				if (p is Int32?)     return ToSqlSingle((Int32?)    p);
				if (p is Int64?)     return ToSqlSingle((Int64?)    p);
				if (p is SByte?)     return ToSqlSingle((SByte?)    p);
				if (p is Single?)    return ToSqlSingle((Single?)   p);
				if (p is UInt16?)    return ToSqlSingle((UInt16?)   p);
				if (p is UInt32?)    return ToSqlSingle((UInt32?)   p);
				if (p is UInt64?)    return ToSqlSingle((UInt64?)   p);
			}

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean) return ToSqlSingle((SqlBoolean)p);
				if (p is SqlByte)    return ToSqlSingle((SqlByte)   p);
				if (p is SqlDecimal) return ToSqlSingle((SqlDecimal)p);
				if (p is SqlDouble)  return ToSqlSingle((SqlDouble) p);
				if (p is SqlInt16)   return ToSqlSingle((SqlInt16)  p);
				if (p is SqlInt32)   return ToSqlSingle((SqlInt32)  p);
				if (p is SqlInt64)   return ToSqlSingle((SqlInt64)  p);
				if (p is SqlMoney)   return ToSqlSingle((SqlMoney)  p);
				if (p is SqlString)  return ToSqlSingle((SqlString) p);
			}

			// Other Types
			//
			if (p is Binary)     return ToSqlSingle((Binary)    p);
			if (p is Byte[])     return ToSqlSingle((Byte[])    p);

			throw CreateInvalidCastException(p.GetType(), typeof(SqlSingle));
		}

#endif

		#endregion

		#region SqlString

#if !SILVERLIGHT

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Boolean         p) { return p.ToString();                                                                     }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Byte            p) { return p.ToString();                                                                     }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Char            p) { return p.ToString();                                                                     }
		/// <summary>Converts the value from <c>DateTime</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(DateTime        p) { return p.ToString();                                                                     }
		/// <summary>Converts the value from <c>DateTimeOffset</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(DateTimeOffset  p) { return p.ToString();                                                                     }
		/// <summary>Converts the value from <c>Decimal</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Decimal         p) { return p.ToString();                                                                     }
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Double          p) { return p.ToString();                                                                     }
		/// <summary>Converts the value from <c>Guid</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Guid            p) { return p.ToString();                                                                     }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Int16           p) { return p.ToString();                                                                     }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Int32           p) { return p.ToString();                                                                     }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Int64           p) { return p.ToString();                                                                     }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>SqlString</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlString ToSqlString(SByte           p) { return p.ToString();                                                                     }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Single          p) { return p.ToString();                                                                     }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(String          p) { return p ?? SqlString.Null;                                                              }
		/// <summary>Converts the value from <c>TimeSpan</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(TimeSpan        p) { return p.ToString();                                                                     }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>SqlString</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlString ToSqlString(UInt16          p) { return p.ToString();                                                                     }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>SqlString</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlString ToSqlString(UInt32          p) { return p.ToString();                                                                     }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>SqlString</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlString ToSqlString(UInt64          p) { return p.ToString();                                                                     }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Boolean?        p) { return p.HasValue ? p.Value.ToString() : SqlString.Null;                                 }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Byte?           p) { return p.HasValue ? p.Value.ToString() : SqlString.Null;                                 }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Char?           p) { return p.HasValue ? p.Value.ToString() : SqlString.Null;                                 }
		/// <summary>Converts the value from <c>DateTime?</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(DateTime?       p) { return p.HasValue ? p.Value.ToString() : SqlString.Null;                                 }
		/// <summary>Converts the value from <c>DateTimeOffset?</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(DateTimeOffset? p) { return p.HasValue ? p.Value.ToString() : SqlString.Null;                                 }
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Decimal?        p) { return p.HasValue ? p.Value.ToString() : SqlString.Null;                                 }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Double?         p) { return p.HasValue ? p.Value.ToString() : SqlString.Null;                                 }
		/// <summary>Converts the value from <c>Guid?</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Guid?           p) { return p.HasValue ? p.Value.ToString() : SqlString.Null;                                 }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Int16?          p) { return p.HasValue ? p.Value.ToString() : SqlString.Null;                                 }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Int32?          p) { return p.HasValue ? p.Value.ToString() : SqlString.Null;                                 }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Int64?          p) { return p.HasValue ? p.Value.ToString() : SqlString.Null;                                 }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>SqlString</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlString ToSqlString(SByte?          p) { return p.HasValue ? p.Value.ToString() : SqlString.Null;                                 }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Single?         p) { return p.HasValue ? p.Value.ToString() : SqlString.Null;                                 }
		/// <summary>Converts the value from <c>TimeSpan?</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(TimeSpan?       p) { return p.HasValue ? p.Value.ToString() : SqlString.Null;                                 }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>SqlString</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlString ToSqlString(UInt16?         p) { return p.HasValue ? p.Value.ToString() : SqlString.Null;                                 }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>SqlString</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlString ToSqlString(UInt32?         p) { return p.HasValue ? p.Value.ToString() : SqlString.Null;                                 }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>SqlString</c> value.</summary>
		[CLSCompliant(false)]
		public static SqlString ToSqlString(UInt64?         p) { return p.HasValue ? p.Value.ToString() : SqlString.Null;                                 }

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(SqlBoolean      p) { return p.ToSqlString();                                                                  }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(SqlByte         p) { return p.ToSqlString();                                                                  }
		/// <summary>Converts the value from <c>SqlChars</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(SqlChars        p) { return p.ToSqlString();                                                                  }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(SqlDecimal      p) { return p.ToSqlString();                                                                  }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(SqlDouble       p) { return p.ToSqlString();                                                                  }
		/// <summary>Converts the value from <c>SqlGuid</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(SqlGuid         p) { return p.ToSqlString();                                                                  }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(SqlInt16        p) { return p.ToSqlString();                                                                  }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(SqlInt32        p) { return p.ToSqlString();                                                                  }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(SqlInt64        p) { return p.ToSqlString();                                                                  }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(SqlMoney        p) { return p.ToSqlString();                                                                  }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(SqlSingle       p) { return p.ToSqlString();                                                                  }
		/// <summary>Converts the value from <c>SqlXml</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(SqlXml          p) { return p.IsNull ? SqlString.Null : p.Value;                                              }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Binary          p) { return ToSqlString(p.ToArray());                                                         }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Byte[]          p) { return p == null ? SqlString.Null : System.Text.Encoding.UTF8.GetString(p, 0, p.Length); }
		/// <summary>Converts the value from <c>Type</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(Type            p) { return p == null ? SqlString.Null : p.FullName;                                          }
		/// <summary>Converts the value from <c>XElement</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(XElement        p) { return p == null ? SqlString.Null : p.ToString();                                        }
		/// <summary>Converts the value from <c>XmlDocument</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(XmlDocument     p) { return p == null ? SqlString.Null : p.InnerXml;                                          }

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>SqlString</c> value.</summary>
		public static SqlString ToSqlString(object p)
		{
			if (p == null) return SqlString.Null;

			if (p is SqlString) return (SqlString)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull    : return SqlString.Null;
				case TypeCode.SByte     : return ToSqlString((SByte)    p);
				case TypeCode.Int16     : return ToSqlString((Int16)    p);
				case TypeCode.Int32     : return ToSqlString((Int32)    p);
				case TypeCode.Int64     : return ToSqlString((Int64)    p);
				case TypeCode.Byte      : return ToSqlString((Byte)     p);
				case TypeCode.UInt16    : return ToSqlString((UInt16)   p);
				case TypeCode.UInt32    : return ToSqlString((UInt32)   p);
				case TypeCode.UInt64    : return ToSqlString((UInt64)   p);
				case TypeCode.Single    : return ToSqlString((Single)   p);
				case TypeCode.Double    : return ToSqlString((Double)   p);
				case TypeCode.Boolean   : return ToSqlString((Boolean)  p);
				case TypeCode.Decimal   : return ToSqlString((Decimal)  p);
				case TypeCode.Char      : return ToSqlString((Char)     p);
				case TypeCode.DateTime  : return ToSqlString((DateTime) p);
				case TypeCode.String    : return ToSqlString((String)   p);
			}

			// Simple Types
			//
			if (p is DateTimeOffset)  return ToSqlString((DateTimeOffset) p);
			if (p is Guid)            return ToSqlString((Guid)           p);
			if (p is TimeSpan)        return ToSqlString((TimeSpan)       p);

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)        return ToSqlString((Boolean?)       p);
				if (p is Byte?)           return ToSqlString((Byte?)          p);
				if (p is Char?)           return ToSqlString((Char?)          p);
				if (p is DateTime?)       return ToSqlString((DateTime?)      p);
				if (p is DateTimeOffset?) return ToSqlString((DateTimeOffset?)p);
				if (p is Decimal?)        return ToSqlString((Decimal?)       p);
				if (p is Double?)         return ToSqlString((Double?)        p);
				if (p is Guid?)           return ToSqlString((Guid?)          p);
				if (p is Int16?)          return ToSqlString((Int16?)         p);
				if (p is Int32?)          return ToSqlString((Int32?)         p);
				if (p is Int64?)          return ToSqlString((Int64?)         p);
				if (p is SByte?)          return ToSqlString((SByte?)         p);
				if (p is Single?)         return ToSqlString((Single?)        p);
				if (p is TimeSpan?)       return ToSqlString((TimeSpan?)      p);
				if (p is UInt16?)         return ToSqlString((UInt16?)        p);
				if (p is UInt32?)         return ToSqlString((UInt32?)        p);
				if (p is UInt64?)         return ToSqlString((UInt64?)        p);
			}

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBoolean)      return ToSqlString((SqlBoolean)     p);
				if (p is SqlByte)         return ToSqlString((SqlByte)        p);
				if (p is SqlChars)        return ToSqlString((SqlChars)       p);
				if (p is SqlDecimal)      return ToSqlString((SqlDecimal)     p);
				if (p is SqlDouble)       return ToSqlString((SqlDouble)      p);
				if (p is SqlGuid)         return ToSqlString((SqlGuid)        p);
				if (p is SqlInt16)        return ToSqlString((SqlInt16)       p);
				if (p is SqlInt32)        return ToSqlString((SqlInt32)       p);
				if (p is SqlInt64)        return ToSqlString((SqlInt64)       p);
				if (p is SqlMoney)        return ToSqlString((SqlMoney)       p);
				if (p is SqlSingle)       return ToSqlString((SqlSingle)      p);
				if (p is SqlXml)          return ToSqlString((SqlXml)         p);
			}

			// Other Types
			//
			if (p is Binary)          return ToSqlString((Binary)         p);
			if (p is Byte[])          return ToSqlString((Byte[])         p);
			if (p is Type)            return ToSqlString((Type)           p);
			if (p is XElement)        return ToSqlString((XElement)       p);
			if (p is XmlDocument)     return ToSqlString((XmlDocument)    p);

			throw CreateInvalidCastException(p.GetType(), typeof(SqlString));
		}

#endif

		#endregion

		#region SqlXml

#if !SILVERLIGHT

		// Simple Types
		//
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>SqlXml</c> value.</summary>
		public static SqlXml ToSqlXml(String      p) { return p == null ? SqlXml.Null : new SqlXml(new XmlTextReader(new StringReader(p)));                    }

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBinary</c> to an equivalent <c>SqlXml</c> value.</summary>
		public static SqlXml ToSqlXml(SqlBinary   p) { return p.IsNull ? SqlXml.Null : new SqlXml(new MemoryStream(p.Value));                                  }
		/// <summary>Converts the value from <c>SqlBytes</c> to an equivalent <c>SqlXml</c> value.</summary>
		public static SqlXml ToSqlXml(SqlBytes    p) { return p.IsNull ? SqlXml.Null : new SqlXml(p.Stream);                                                   }
		/// <summary>Converts the value from <c>SqlChars</c> to an equivalent <c>SqlXml</c> value.</summary>
		public static SqlXml ToSqlXml(SqlChars    p) { return p.IsNull ? SqlXml.Null : new SqlXml(new XmlTextReader(new StringReader(p.ToSqlString().Value))); }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>SqlXml</c> value.</summary>
		public static SqlXml ToSqlXml(SqlString   p) { return p.IsNull ? SqlXml.Null : new SqlXml(new XmlTextReader(new StringReader(p.Value)));               }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>SqlXml</c> value.</summary>
		public static SqlXml ToSqlXml(Binary      p) { return p == null ? SqlXml.Null : new SqlXml(new MemoryStream(p.ToArray()));                             }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>SqlXml</c> value.</summary>
		public static SqlXml ToSqlXml(Byte[]      p) { return p == null ? SqlXml.Null : new SqlXml(new MemoryStream(p));                                       }
		/// <summary>Converts the value from <c>Char[]</c> to an equivalent <c>SqlXml</c> value.</summary>
		public static SqlXml ToSqlXml(Char[]      p) { return p == null ? SqlXml.Null : new SqlXml(new XmlTextReader(new StringReader(new string(p))));        }
		/// <summary>Converts the value from <c>Stream</c> to an equivalent <c>SqlXml</c> value.</summary>
		public static SqlXml ToSqlXml(Stream      p) { return p == null ? SqlXml.Null : new SqlXml(p);                                                         }
		/// <summary>Converts the value from <c>XElement</c> to an equivalent <c>SqlXml</c> value.</summary>
		public static SqlXml ToSqlXml(XElement    p) { return p == null ? SqlXml.Null : new SqlXml(new XmlTextReader(new StringReader(p.ToString())));         }
		/// <summary>Converts the value from <c>XmlDocument</c> to an equivalent <c>SqlXml</c> value.</summary>
		public static SqlXml ToSqlXml(XmlDocument p) { return p == null ? SqlXml.Null : new SqlXml(new XmlTextReader(new StringReader(p.InnerXml)));           }
		/// <summary>Converts the value from <c>XmlReader</c> to an equivalent <c>SqlXml</c> value.</summary>
		public static SqlXml ToSqlXml(XmlReader   p) { return p == null ? SqlXml.Null : new SqlXml(p);                                                         }

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>SqlXml</c> value.</summary>
		public static SqlXml ToSqlXml(object p)
		{
			if (p == null) return SqlXml.Null;

			if (p is SqlXml) return (SqlXml)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull : return SqlXml.Null;
				case TypeCode.String : return ToSqlXml((String)p);
			}

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBinary)   return ToSqlXml((SqlBinary)  p);
				if (p is SqlBytes)    return ToSqlXml((SqlBytes)   p);
				if (p is SqlChars)    return ToSqlXml((SqlChars)   p);
				if (p is SqlString)   return ToSqlXml((SqlString)  p);
			}

			// Other Types
			//
			if (p is Binary)      return ToSqlXml((Binary)     p);
			if (p is Byte[])      return ToSqlXml((Byte[])     p);
			if (p is Char[])      return ToSqlXml((Char[])     p);
			if (p is Stream)      return ToSqlXml((Stream)     p);
			if (p is XElement)    return ToSqlXml((XElement)   p);
			if (p is XmlDocument) return ToSqlXml((XmlDocument)p);
			if (p is XmlReader)   return ToSqlXml((XmlReader)  p);

			throw CreateInvalidCastException(p.GetType(), typeof(SqlXml));
		}

#endif

		#endregion

		#endregion

		#region Other Types

		#region Binary

		#endregion

		#region Byte[]

		// Simple Types
		//
		/// <summary>Converts the value from <c>Boolean</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(Boolean         p) { return BitConverter.GetBytes(p);                                         }
		/// <summary>Converts the value from <c>Byte</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(Byte            p) { return new[] { p };                                                      }
		/// <summary>Converts the value from <c>Char</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(Char            p) { return BitConverter.GetBytes(p);                                         }
#if !SILVERLIGHT
		/// <summary>Converts the value from <c>DateTime</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(DateTime        p) { return ToByteArray(p.ToBinary());                                        }
#endif
#if !SILVERLIGHT
		/// <summary>Converts the value from <c>DateTimeOffset</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(DateTimeOffset  p) { return ToByteArray(p.LocalDateTime.ToBinary());                          }
#endif
		/// <summary>Converts the value from <c>Double</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(Double          p) { return BitConverter.GetBytes(p);                                         }
		/// <summary>Converts the value from <c>Guid</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(Guid            p) { return p == Guid.Empty ? (Byte[])null : p.ToByteArray();                 }
		/// <summary>Converts the value from <c>Int16</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(Int16           p) { return BitConverter.GetBytes(p);                                         }
		/// <summary>Converts the value from <c>Int32</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(Int32           p) { return BitConverter.GetBytes(p);                                         }
		/// <summary>Converts the value from <c>Int64</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(Int64           p) { return BitConverter.GetBytes(p);                                         }
		/// <summary>Converts the value from <c>SByte</c> to an equivalent <c>Byte[]</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte[] ToByteArray(SByte           p) { return new[] { checked((Byte)p) };                                       }
		/// <summary>Converts the value from <c>Single</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(Single          p) { return BitConverter.GetBytes(p);                                         }
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(String          p) { return p == null ? (Byte[])null : System.Text.Encoding.UTF8.GetBytes(p); }
		/// <summary>Converts the value from <c>TimeSpan</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(TimeSpan        p) { return ToByteArray(p.Ticks);                                             }
		/// <summary>Converts the value from <c>UInt16</c> to an equivalent <c>Byte[]</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte[] ToByteArray(UInt16          p) { return BitConverter.GetBytes(p);                                         }
		/// <summary>Converts the value from <c>UInt32</c> to an equivalent <c>Byte[]</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte[] ToByteArray(UInt32          p) { return BitConverter.GetBytes(p);                                         }
		/// <summary>Converts the value from <c>UInt64</c> to an equivalent <c>Byte[]</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte[] ToByteArray(UInt64          p) { return BitConverter.GetBytes(p);                                         }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Boolean?</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(Boolean?        p) { return p.HasValue ? ToByteArray(p.Value) : (Byte[])null;                 }
		/// <summary>Converts the value from <c>Byte?</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(Byte?           p) { return p.HasValue ? ToByteArray(p.Value) : (Byte[])null;                 }
		/// <summary>Converts the value from <c>Char?</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(Char?           p) { return p.HasValue ? ToByteArray(p.Value) : (Byte[])null;                 }
#if !SILVERLIGHT
		/// <summary>Converts the value from <c>DateTime?</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(DateTime?       p) { return p.HasValue ? ToByteArray(p.Value) : (Byte[])null;                 }
#endif
#if !SILVERLIGHT
		/// <summary>Converts the value from <c>DateTimeOffset?</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(DateTimeOffset? p) { return p.HasValue ? ToByteArray(p.Value) : (Byte[])null;                 }
#endif
		/// <summary>Converts the value from <c>Decimal?</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(Decimal?        p) { return p.HasValue ? ToByteArray(p.Value) : (Byte[])null;                 }
		/// <summary>Converts the value from <c>Double?</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(Double?         p) { return p.HasValue ? ToByteArray(p.Value) : (Byte[])null;                 }
		/// <summary>Converts the value from <c>Guid?</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(Guid?           p) { return p.HasValue ? ToByteArray(p.Value) : (Byte[])null;                 }
		/// <summary>Converts the value from <c>Int16?</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(Int16?          p) { return p.HasValue ? ToByteArray(p.Value) : (Byte[])null;                 }
		/// <summary>Converts the value from <c>Int32?</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(Int32?          p) { return p.HasValue ? ToByteArray(p.Value) : (Byte[])null;                 }
		/// <summary>Converts the value from <c>Int64?</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(Int64?          p) { return p.HasValue ? ToByteArray(p.Value) : (Byte[])null;                 }
		/// <summary>Converts the value from <c>SByte?</c> to an equivalent <c>Byte[]</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte[] ToByteArray(SByte?          p) { return p.HasValue ? ToByteArray(p.Value) : (Byte[])null;                 }
		/// <summary>Converts the value from <c>Single?</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(Single?         p) { return p.HasValue ? ToByteArray(p.Value) : (Byte[])null;                 }
		/// <summary>Converts the value from <c>TimeSpan?</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(TimeSpan?       p) { return p.HasValue ? ToByteArray(p.Value) : (Byte[])null;                 }
		/// <summary>Converts the value from <c>UInt16?</c> to an equivalent <c>Byte[]</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte[] ToByteArray(UInt16?         p) { return p.HasValue ? ToByteArray(p.Value) : (Byte[])null;                 }
		/// <summary>Converts the value from <c>UInt32?</c> to an equivalent <c>Byte[]</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte[] ToByteArray(UInt32?         p) { return p.HasValue ? ToByteArray(p.Value) : (Byte[])null;                 }
		/// <summary>Converts the value from <c>UInt64?</c> to an equivalent <c>Byte[]</c> value.</summary>
		[CLSCompliant(false)]
		public static Byte[] ToByteArray(UInt64?         p) { return p.HasValue ? ToByteArray(p.Value) : (Byte[])null;                 }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(Binary          p) { return p == null ? (Byte[])null : p.ToArray();                           }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBinary</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(SqlBinary       p) { return p.IsNull ? (Byte[])null : p.Value;                                }
		/// <summary>Converts the value from <c>SqlBoolean</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(SqlBoolean      p) { return p.IsNull ? (Byte[])null : ToByteArray(p.Value);                   }
		/// <summary>Converts the value from <c>SqlByte</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(SqlByte         p) { return p.IsNull ? (Byte[])null : ToByteArray(p.Value);                   }
		/// <summary>Converts the value from <c>SqlBytes</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(SqlBytes        p) { return p.IsNull ? (Byte[])null : p.Value;                                }
		/// <summary>Converts the value from <c>SqlDecimal</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(SqlDecimal      p) { return p.IsNull ? (Byte[])null : ToByteArray(p.Value);                   }
		/// <summary>Converts the value from <c>SqlDouble</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(SqlDouble       p) { return p.IsNull ? (Byte[])null : ToByteArray(p.Value);                   }
		/// <summary>Converts the value from <c>SqlGuid</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(SqlGuid         p) { return p.IsNull ? (Byte[])null : p.ToByteArray();                        }
		/// <summary>Converts the value from <c>SqlInt16</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(SqlInt16        p) { return p.IsNull ? (Byte[])null : ToByteArray(p.Value);                   }
		/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(SqlInt32        p) { return p.IsNull ? (Byte[])null : ToByteArray(p.Value);                   }
		/// <summary>Converts the value from <c>SqlInt64</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(SqlInt64        p) { return p.IsNull ? (Byte[])null : ToByteArray(p.Value);                   }
		/// <summary>Converts the value from <c>SqlMoney</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(SqlMoney        p) { return p.IsNull ? (Byte[])null : ToByteArray(p.Value);                   }
		/// <summary>Converts the value from <c>SqlSingle</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(SqlSingle       p) { return p.IsNull ? (Byte[])null : ToByteArray(p.Value);                   }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(SqlString       p) { return p.IsNull ? (Byte[])null : ToByteArray(p.Value);                   }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(object p)
		{
			if (p == null) return null;

			if (p is Byte[]) return (Byte[])p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull   : return null;
				case TypeCode.Decimal  : return ToByteArray((Decimal) p);
				case TypeCode.String   : return ToByteArray((String)  p);
				case TypeCode.Byte     : return ToByteArray((Byte)    p);
				case TypeCode.SByte    : return ToByteArray((SByte)   p);
#if !SILVERLIGHT
				case TypeCode.DateTime : return ToByteArray((DateTime)p);
#endif
				case TypeCode.Int16    : return ToByteArray((Int16)   p);
				case TypeCode.Int32    : return ToByteArray((Int32)   p);
				case TypeCode.Int64    : return ToByteArray((Int64)   p);
				case TypeCode.UInt16   : return ToByteArray((UInt16)  p);
				case TypeCode.UInt32   : return ToByteArray((UInt32)  p);
				case TypeCode.UInt64   : return ToByteArray((UInt64)  p);
				case TypeCode.Single   : return ToByteArray((Single)  p);
				case TypeCode.Double   : return ToByteArray((Double)  p);
				case TypeCode.Boolean  : return ToByteArray((Boolean) p);
				case TypeCode.Char     : return ToByteArray((Char)    p);
			}

			// Simple Types
			//
#if !SILVERLIGHT
			if (p is DateTimeOffset)  return ToByteArray((DateTimeOffset) p);
#endif
			if (p is Guid)            return ToByteArray((Guid)           p);
			if (p is TimeSpan)        return ToByteArray((TimeSpan)       p);

			// Nullable Types
			//
			if (type.IsGenericType)
			{
				if (p is Boolean?)        return ToByteArray((Boolean?)       p);
				if (p is Byte?)           return ToByteArray((Byte?)          p);
				if (p is Char?)           return ToByteArray((Char?)          p);
#if !SILVERLIGHT
				if (p is DateTime?)       return ToByteArray((DateTime?)      p);
#endif
#if !SILVERLIGHT
				if (p is DateTimeOffset?) return ToByteArray((DateTimeOffset?)p);
#endif
				if (p is Decimal?)        return ToByteArray((Decimal?)       p);
				if (p is Double?)         return ToByteArray((Double?)        p);
				if (p is Guid?)           return ToByteArray((Guid?)          p);
				if (p is Int16?)          return ToByteArray((Int16?)         p);
				if (p is Int32?)          return ToByteArray((Int32?)         p);
				if (p is Int64?)          return ToByteArray((Int64?)         p);
				if (p is SByte?)          return ToByteArray((SByte?)         p);
				if (p is Single?)         return ToByteArray((Single?)        p);
				if (p is TimeSpan?)       return ToByteArray((TimeSpan?)      p);
				if (p is UInt16?)         return ToByteArray((UInt16?)        p);
				if (p is UInt32?)         return ToByteArray((UInt32?)        p);
				if (p is UInt64?)         return ToByteArray((UInt64?)        p);
			}

			// Other Types
			//
			if (p is Binary)          return ToByteArray((Binary)         p);
			if (p is Char[])          return ToByteArray((Char[])         p);
			if (p is Stream)          return ToByteArray((Stream)         p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBinary)       return ToByteArray((SqlBinary)      p);
				if (p is SqlBoolean)      return ToByteArray((SqlBoolean)     p);
				if (p is SqlByte)         return ToByteArray((SqlByte)        p);
				if (p is SqlBytes)        return ToByteArray((SqlBytes)       p);
				if (p is SqlDecimal)      return ToByteArray((SqlDecimal)     p);
				if (p is SqlDouble)       return ToByteArray((SqlDouble)      p);
				if (p is SqlGuid)         return ToByteArray((SqlGuid)        p);
				if (p is SqlInt16)        return ToByteArray((SqlInt16)       p);
				if (p is SqlInt32)        return ToByteArray((SqlInt32)       p);
				if (p is SqlInt64)        return ToByteArray((SqlInt64)       p);
				if (p is SqlMoney)        return ToByteArray((SqlMoney)       p);
				if (p is SqlSingle)       return ToByteArray((SqlSingle)      p);
				if (p is SqlString)       return ToByteArray((SqlString)      p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(Byte[]));
		}

		#endregion

		#region Char[]

		#endregion

		#region Stream

		// Simple Types
		//
		/// <summary>Converts the value from <c>Guid</c> to an equivalent <c>Stream</c> value.</summary>
		public static Stream ToStream(Guid      p) { return p == Guid.Empty ? Stream.Null : new MemoryStream(p.ToByteArray());  }

		// Nullable Types
		//
		/// <summary>Converts the value from <c>Guid?</c> to an equivalent <c>Stream</c> value.</summary>
		public static Stream ToStream(Guid?     p) { return p.HasValue ? new MemoryStream(p.Value.ToByteArray()) : Stream.Null; }

		// Other Types
		//
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Stream</c> value.</summary>
		public static Stream ToStream(Binary    p) { return p == null ? Stream.Null : new MemoryStream(p.ToArray());            }
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>Stream</c> value.</summary>
		public static Stream ToStream(Byte[]    p) { return p == null ? Stream.Null : new MemoryStream(p);                      }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlBinary</c> to an equivalent <c>Stream</c> value.</summary>
		public static Stream ToStream(SqlBinary p) { return p.IsNull ? Stream.Null : new MemoryStream(p.Value);                 }
		/// <summary>Converts the value from <c>SqlBytes</c> to an equivalent <c>Stream</c> value.</summary>
		public static Stream ToStream(SqlBytes  p) { return p.IsNull ? Stream.Null : p.Stream;                                  }
		/// <summary>Converts the value from <c>SqlGuid</c> to an equivalent <c>Stream</c> value.</summary>
		public static Stream ToStream(SqlGuid   p) { return p.IsNull ? Stream.Null : new MemoryStream(p.Value.ToByteArray());   }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Stream</c> value.</summary>
		public static Stream ToStream(object p)
		{
			if (p == null || p is DBNull) return Stream.Null;

			if (p is Stream) return (Stream)p;

			// Simple Types
			//
			if (p is Guid)      return ToStream((Guid)     p);

			// Nullable Types
			//
			var type = p.GetType();

			if (type.IsGenericType)
			{
				if (p is Guid?)     return ToStream((Guid?)    p);
			}

			// Other Types
			//
			if (p is Binary)    return ToStream((Binary)   p);
			if (p is Byte[])    return ToStream((Byte[])   p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlBinary) return ToStream((SqlBinary)p);
				if (p is SqlBytes)  return ToStream((SqlBytes) p);
				if (p is SqlGuid)   return ToStream((SqlGuid)  p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(Stream));
		}

		#endregion

		#region Type

		// Simple Types
		//
#if !SILVERLIGHT
		/// <summary>Converts the value from <c>Guid</c> to an equivalent <c>Type</c> value.</summary>
		public static Type ToType(Guid      p) { return p == Guid.Empty ? (Type)null : Type.GetTypeFromCLSID(p);             }
#endif
		/// <summary>Converts the value from <c>String</c> to an equivalent <c>Type</c> value.</summary>
		public static Type ToType(String    p) { return p == null ? (Type)null : Type.GetType(p);                            }

		// Nullable Types
		//
#if !SILVERLIGHT
		/// <summary>Converts the value from <c>Guid?</c> to an equivalent <c>Type</c> value.</summary>
		public static Type ToType(Guid?     p) { return p.HasValue ? Type.GetTypeFromCLSID(p.Value) : (Type)null;            }
#endif

		// Other Types
		//
#if !SILVERLIGHT
		/// <summary>Converts the value from <c>Binary</c> to an equivalent <c>Type</c> value.</summary>
		public static Type ToType(Binary    p) { return p == null ? (Type)null : Type.GetTypeFromCLSID(ToGuid(p.ToArray())); }
#endif
#if !SILVERLIGHT
		/// <summary>Converts the value from <c>Byte[]</c> to an equivalent <c>Type</c> value.</summary>
		public static Type ToType(Byte[]    p) { return p == null ? (Type)null : Type.GetTypeFromCLSID(ToGuid(p));           }
#endif
		/// <summary>Converts the value from <c>Char[]</c> to an equivalent <c>Type</c> value.</summary>
		public static Type ToType(Char[]    p) { return p == null ? (Type)null : Type.GetType(new string(p));                }

#if !SILVERLIGHT

		// Sql Types
		//
		/// <summary>Converts the value from <c>SqlChars</c> to an equivalent <c>Type</c> value.</summary>
		public static Type ToType(SqlChars  p) { return p.IsNull ? (Type)null : Type.GetType(new string(p.Value));           }
		/// <summary>Converts the value from <c>SqlGuid</c> to an equivalent <c>Type</c> value.</summary>
		public static Type ToType(SqlGuid   p) { return p.IsNull ? (Type)null : Type.GetTypeFromCLSID(p.Value);              }
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>Type</c> value.</summary>
		public static Type ToType(SqlString p) { return p.IsNull ? (Type)null : Type.GetType(p.Value);                       }

#endif

		// From Object
		//
		/// <summary>Converts the value from <c>Object</c> to an equivalent <c>Type</c> value.</summary>
		public static Type ToType(object p)
		{
			if (p == null) return null;

			if (p is Type) return (Type)p;

			var type = p.GetType();

			// Primitive types
			//
			switch (Type.GetTypeCode(type))
			{
				case TypeCode.DBNull : return null;
				case TypeCode.String : return ToType((String)p);
			}

			// Simple Types
			//
#if !SILVERLIGHT
			if (p is Guid)      return ToType((Guid)     p);
#endif

			// Nullable Types
			//
			if (type.IsGenericType)
			{
#if !SILVERLIGHT
				if (p is Guid?)     return ToType((Guid?)    p);
#endif
			}

			// Other Types
			//
#if !SILVERLIGHT
			if (p is Binary)    return ToType((Binary)   p);
#endif
#if !SILVERLIGHT
			if (p is Byte[])    return ToType((Byte[])   p);
#endif
			if (p is Char[])    return ToType((Char[])   p);

#if !SILVERLIGHT

			// Sql Types
			//
			if (p is INullable)
			{
				if (p is SqlChars)  return ToType((SqlChars) p);
				if (p is SqlGuid)   return ToType((SqlGuid)  p);
				if (p is SqlString) return ToType((SqlString)p);
			}

#endif

			throw CreateInvalidCastException(p.GetType(), typeof(Type));
		}

		#endregion

		#region XmlDocument

#if !SILVERLIGHT

#endif

		#endregion

		#region XmlReader

#if !SILVERLIGHT

#endif

		#endregion

		#endregion
	}
}