nice! I wasn't aware it was that easy :)

Thanks much

On Jun 29, 5:21 am, jalchr <[email protected]> wrote:
> I use '^' as a delimiter but same concept ...
>
>             Map(x =>
> x.ExternalNotes).CustomType(typeof(StringArrayTypeMapper));
>
>     public class StringArrayTypeMapper : PrimitiveType
>     {
>         public StringArrayTypeMapper()
>             : base(new SqlType(DbType.String))
>         {
>         }
>
>         public override object Get(IDataReader rs, int index)
>         {
>             var value = rs.GetString(index);
>             return value.Split('c');
>         }
>
>         public override object Get(IDataReader rs, string name)
>         {
>             int ordinal = rs.GetOrdinal(name);
>             return Get(rs, ordinal);
>         }
>
>         public override Type ReturnedClass
>         {
>             get { return typeof(string[]); }
>         }
>
>         public override object FromStringValue(string xml)
>         {
>             return xml.Split('^');
>         }
>
>         public override string Name
>         {
>             get { return "string[]"; }
>         }
>
>         public override void Set(IDbCommand cmd, object value, int index)
>         {
>             var parameter = (IDataParameter)cmd.Parameters[index];
>
>             var val = (string[])value;
>
>             parameter.Value = string.Join("^", val);
>         }
>         public virtual object NullSafeGet(IDataReader resultSet, string[]
> names, object owner)
>         {
>             int index = resultSet.GetOrdinal(names[0]);
>             if (resultSet.IsDBNull(index))
>             {
>                 return null;
>             }
>             string res = resultSet.GetValue(index) as string;
>             if (res != null)
>             {
>                 return res.Split('^');
>             }
>             throw new NotImplementedException();
>         }
>         public virtual void NullSafeSet(IDbCommand cmd, object value, int
> index)
>         {
>             IDbDataParameter parameter =
> ((IDbDataParameter)cmd.Parameters[index]);
>             if (value == null)
>             {
>                 parameter.Value = DBNull.Value;
>             }
>             else
>             {
>                 var list = (string[])value;
>                 parameter.Value = string.Join("^", list);
>             }
>         }
>         public override string ObjectToSQLString(object value, Dialect
> dialect)
>         {
>             return value.ToString();
>         }
>
>         public override Type PrimitiveClass
>         {
>             get { return typeof(string[]); }
>         }
>
>         public override object DefaultValue
>         {
>             get { return null; }
>         }
>     }

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to