C# Fluent NHibernate-使用自定义映射映射枚举列表

C# Fluent NHibernate-使用自定义映射映射枚举列表,c#,collections,enums,fluent-nhibernate,iusertype,C#,Collections,Enums,Fluent Nhibernate,Iusertype,在我们的解决方案中,在映射枚举时,不是简单地保存整数或文本描述,而是使用自定义的IUserType根据数据库表解析文本描述并检索适当的ID。(这些值在应用程序启动时缓存以加快处理速度) 这对于单枚举属性来说非常有效。映射代码(使用映射覆盖)如下所示 POCO: public class Connection { // Other properties omitted public Protocol Protocol { get; set; } } pub

在我们的解决方案中,在映射枚举时,不是简单地保存整数或文本描述,而是使用自定义的
IUserType
根据数据库表解析文本描述并检索适当的ID。(这些值在应用程序启动时缓存以加快处理速度)

这对于单枚举属性来说非常有效。映射代码(使用映射覆盖)如下所示

POCO:

  public class Connection
  {
      // Other properties omitted
      public Protocol Protocol { get; set; }
  }
  public class Credential
  {
      // Other properties omitted
      public ICollection<Protocol> Protocols { get; set; }
  }
映射覆盖:

  mapping.Map(map => map.Protocol, "ProtocolID")
         .CustomType<GenericEnumUserType<Protocol>>();
。。。但是我不知道如何在
映射您的自定义类型
部分中连接
自定义类型

另一方面,建议收藏中不提供
CustomType
,但该评论的日期为2009年,因此我希望从那时起有所改变

这种类型的映射是可能的(如果可能的话,我遗漏了什么),还是我需要开始寻找最合适的解决方法

干杯

  mapping.HasMany(x => x.Protocols)
         .Table("TABLE")
         .KeyColumn("COLUMN")
         .Component(component =>
                   {
                           //MAP YOUR CUSTOM TYPE HERE
                   })
         .Cascade.None()
         .KeyNullable()
         .Not.LazyLoad();