publicclassIpAddressAsString:UserType{#region Overrides of UserTypepublicoverrideobjectNullSafeGet(IDataReaderrs,string[]names,objectowner){objectobj=NHibernateUtil.String.NullSafeGet(rs,names);if(obj==null){returnnull;}returnIPAddress.Parse(obj.ToString());}publicoverridevoidNullSafeSet(IDbCommandcmd,objectvalue,intindex){Check.Require(cmd!=null);if(value==null){((IDataParameter)cmd.Parameters[index]).Value=DBNull.Value;}else{((IDataParameter)cmd.Parameters[index]).Value=value.ToString();}}publicoverrideSqlType[]SqlTypes{get{returnnewSqlType[]{SqlTypeFactory.GetString(15)};}}publicoverrideTypeReturnedType{get{returntypeof(IPAddress);}}#endregion}
I’d recently used this class to stored failed and successful logon attempts. Again it’s just too simple but I’m happy to share.