5

If I have a field in the db which stores a set of comma separated strings (says tags), how can I instruct fluent Nhibernate to pick it up at List<string>()
e.g.

Public IList<string> Tags {get; set;}

Db field values:

Mvc, .net, FNH 
Quintin Par
  • 15,862
  • 27
  • 93
  • 146

2 Answers2

2

IUserType is what you're looking for.

You'll need to implement that interface to provide a mapping from/to the comma separated strings from/to the List.

Personally, I'd leave it alone and project the tags as IEnumerable using a Regex.

Diego Mijelshon
  • 52,548
  • 16
  • 116
  • 154
1

From NHusers list:

One method:

private string NonRelationalTags 
{ get  { return joinlist(Tags); } 
set
{Tags = parselist(value);}}  

map this with NH using normal or equivalent.

Quintin Par
  • 15,862
  • 27
  • 93
  • 146