How to map Dictionary<enum1,enum2> with Fluent Nhibernate

▼魔方 西西 提交于 2019-12-08 08:43:14

问题


I was mapping a relation using something like the following

<map name="Foo" cascade="all-delete-orphan" lazy="false">
  <key column="FooId"/>
  <index column="FooType" type="Domain.Enum.FooType, Domain"/>
  <element column ="FooStatus" type="Domain.Enum.FooStatus, Domain"/>
</map>

The class is like this

namespace Domain {
    public class Enum {
        public enum FooType {
            Foo1,
            Foo2,
            ...
      Foo50}
       public enum FooStatus {
           NotNeeded,
           NeededFor1,
           NeededFor2,
      NeededFor3,
      NiceToHave}
    }
}

Can I do this using Fluent Nhibernate? If not can I map a class mixing Fluent and XML?


回答1:


ANSWER From Fluent NHibernate Google group were I asked the same question

The short answer is no, you cannot do this with the fluent interface at the moment. My initial implementation of AsMap() was rather naive and does not support your scenario. I will raise it as an issue and get back to you once a fix is in place but in the meantime you should be able to work around it by mixing xml with fluent mappings. I know we have several users that are currently doing this. The exact steps would depend on how you have it set up.

Paul Batum




回答2:


Forget to add

namespace Domain 
{
public virtual IDictionary<FooType, FooStatus> MyFoo { set; get; }
}


来源:https://stackoverflow.com/questions/243464/how-to-map-dictionaryenum1-enum2-with-fluent-nhibernate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!