Subsonic 亚音速3:简单的假设。如何将枚举映射到表列

Subsonic 亚音速3:简单的假设。如何将枚举映射到表列,subsonic,subsonic3,Subsonic,Subsonic3,我有一个DB表(配置文件)来描述一个人。此表有一列“Sex”(int)。 在.NET部分中,我有: public enum Sex { Male = 1, Female = 2 } public class Profile{ public int ID {get; set;} public Sex Sex {get; set;} } ... SimpleRepository _repo = new SimpleRepository("ConnectionString"); _

我有一个DB表(配置文件)来描述一个人。此表有一列“Sex”(int)。 在.NET部分中,我有:

public enum Sex { Male = 1, Female = 2 } 

public class Profile{
    public int ID {get; set;}
    public Sex Sex {get; set;}
}
...
SimpleRepository _repo = new SimpleRepository("ConnectionString");
_repo.Add<Profile>(profile);
公共枚举性别{男性=1,女性=2}
公共班级简介{
公共int ID{get;set;}
公共性{get;set;}
}
...
SimpleRepository _repo=新SimpleRepository(“连接字符串”);
_回购增加(简介);
此操作后,亚音速将插入新行,但“Sex”字段为空。我尝试将INT和VARCHAR类型用于“Sex”列,但没有任何结果。我还尝试了enum的另一个名称,例如“SexEnum”。 你有什么想法吗?可能需要某种名称约定,也可能是表列的特殊类型。
提前谢谢。

我假设您已经习惯使用.nettiers之类的工具从查找表生成枚举,但是亚音速不提供此功能。 如果表中有SexId列,则可以执行以下操作(需要添加空检查):

public enum Sex { Male = 1, Female = 2 } 

public class Profile{
  public int ID {get; set;}
  public Sex Sex 
  {
    get { return (Sex)SexId; }
    set { SexId = (int)value; }
  }
  int SexId {get; set;}
}