开发者

Mapping collection of enum in NHibernate

开发者 https://www.devze.com 2023-01-10 02:35 出处:网络
I have a class with collection of enums: Class1.cs public enum Language { Serbian = 1, Croatian, Ukrainian,

I have a class with collection of enums:

Class1.cs

public enum Language
{
    Serbian = 1,
    Croatian,
    Ukrainian,
}

public class Class1
{
   private IList<Language> m_languages = new List<Language>();
   public virtual IList<Language> Languages
   {
          get { return m_language开发者_JAVA百科s; }
          set { m_languages = value; }
   }
}

What is the content of mapping file for this class?


As an alternative, you may want to consider something a little 'smarter' than enums; take for instance Fabio's Well Known Instance Type example - I find myself using these all the time for (relatively) static data.


Google is your friend: http://www.lostechies.com/blogs/sean_chambers/archive/2008/04/06/mapping-an-collection-of-enums-with-nhibernate.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消