相关疑难解决方法(0)

映射到枚举列表?

我需要使用NHibernate将具有Enums列表的类映射到db表

这是对象

public class Driver : IIdentity
{
    private IList<Licence> licences;

    /// <summary>
    /// The drivers licences
    /// </summary>
    public virtual IList<Licence> Licences
    {
        get
        {
            return this.licences;
        }
        set
        {
            this.licences = value;
        }
    }
    ..... rest of the class ....
}

//the enum
public enum Licence
{
    FivePersonCar = 5,
    SixPersonCar = 6
}
Run Code Online (Sandbox Code Playgroud)

----------------这里是DB表

TABLE [dbo].[DriverLicence]( [DriverId] [int] NOT NULL, [Level] [int] NOT NULL)

TABLE [dbo].[Driver]( [DriverId] [int] NOT NULL, [Name] [varchar](150) NULL)

-------------这是我的驱动程序的Fluent地图

public class DriverMap …
Run Code Online (Sandbox Code Playgroud)

c# nhibernate orm fluent-nhibernate

3
推荐指数
1
解决办法
2603
查看次数

标签 统计

c# ×1

fluent-nhibernate ×1

nhibernate ×1

orm ×1