I want to store a set of enums
in NHibernate, possibly in delimited format using |
or ,
. I'd like to do it flat, that is, no associated tables (which is overkill for my situation).
Now, I can use an enum
and store one selection (i.e., drop down or radio button) with no problem:
public enum Test
{
Choice1, Choice2, Choice3
}
public virtual Test? TestRadioButtons { get; set }
If the user picks Choice1
, that will be saved in the database by NHibernate. But if I want the option for multiple selections, using the Test
enum above, such as a check box list, I am having no luck:
public virtual List<Test> TestCheckBoxList { get; set; }
or
public virtual List<string> TestCheckBoxList { get; set; }
will throw errors (I get a "table doesn't exist" error for the former, and Generic.List vs. generic.icollection or some variation for the latter). If a user picks "Choice1" and "Choice2" from the checkbox list, only "Choice1" is saved. Again, for my situation, creating separate tables is overkill.
Is it impossible to store multiple enums as some sort of delimited list in NHibernate?