Skip to content

Instantly share code, notes, and snippets.

@ChrisMcKee
Last active December 10, 2015 15:09
Show Gist options
  • Select an option

  • Save ChrisMcKee/4452679 to your computer and use it in GitHub Desktop.

Select an option

Save ChrisMcKee/4452679 to your computer and use it in GitHub Desktop.
Storing delimited data in a column using NHibernate
//Mapped like this
Map(x => x.Roles).CustomType(typeof(string)).Access.CamelCaseField(Prefix.Underscore);
//Something like this
protected string _roles;
public virtual List<string> Roles
{
get
{
if (String.IsNullOrEmpty(_roles)) return new List<string>();
return _roles.Split(new[] {"|"}, StringSplitOptions.None).ToList();
}
set { _roles = string.Join("|", value); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment