I try to map a collection of enumerations to NHibernate using Fluent NHibernate, and then query against the contents of this collection of enumerations, but the system throws exceptions every time.
I have a Widget class mapped to a Widget table. There is also a WidgetType enumeration, and a single Widget instance can have many WidgetTypes types displayed through the WidgetTypes property. The property must be mapped to a separate WidgetTypeRef table with two integer columns: WidgetId and WidgetType.
public class Widget
{
public IList<WidgetType> WidgetTypes { get; set; }
}
public enum WidgetType
{
SomeType = 0,
SomeOtherType = 1,
YetOneMoreType = 2
}
public partial class WidgetMapping : IAutoMappingOverride<Widget>
{
public void Override(AutoMapping<Widget> mapping)
{
mapping.HasMany(w => w.WidgetTypes)
.Table("WidgetTypeRef")
.KeyColumn("WidgetId")
.Element("WidgetType");
}
}
; . WidgetType, , . Ref.
, ".CustomType(typeof (someTypeEnum)", CustomType HasMany. HasMany , " .
? ? Fluent? ( Any Contains)?