列未创建

时间:2010-01-07 11:38:03

标签: subsonic simplerepository

我在我的新项目中使用Subsonic(SimpleRepository)并喜欢使用它但是......

有一个,只有我的一个表,它不会创建所有列,我不明白为什么。

以下是代码:

public class Rating
{
    public Rating()
    {
        UsernameVotant = "";
        UsernameEvaluate = "";
        Note = 0.0;
        NoteAccueil = 0.0;
        NotePedagogie = 0.0;
        NoteRapportQP = 0.0;
        NoteContenu = 0.0;
        Comment = "";
        stageId = 0;
        DateNote = DateTime.Now;
        isValidate = false;
    }
    [SubSonicPrimaryKey]
    public int ID { get; set; }
    public DateTime DateNote;
    public int stageId;
    public string UsernameVotant;
    public string UsernameEvaluate;
    public int Note;
    public int NoteAccueil;
    public double NotePedagogie;
    public double NoteRapportQP;
    public double NoteContenu;
    [SubSonicLongString]
    public string Comment { get; set; } 
    public bool isValidate { get; set; }
}

像我的其他课程一样打电话:

IRepository _repoRun = new SimpleRepository(Core.Config.ArticlesDB,SimpleRepositoryOptions.RunMigrations);

   public bool AddRating(Rating p)
    {
        _repoRun.Add<Rating>(p);
        return true;
    }

创建的表格包含列: ID,Comment,isValidate

无论我尝试添加什么作为默认值,3列包含值: ID = 1(2,3,4 ......) - &gt;作品 评论=“” isValidate = false


正如我注意到一个命名列“Read”的问题,我试图重命名列,重命名表(这是“投票”[法语])但问题与我的原始表格相同“投票“

你能帮帮我吗?

提前致谢(对不起我的英文)

1 个答案:

答案 0 :(得分:2)

您在该类中定义的唯一属性是ID,Comment和isValidate,因此这些是SubSonic将生成的唯一列。将您的字段更改为属性,SubSonic应为其创建列:

[SubSonicPrimaryKey]
public int ID { get; set; }
public DateTime DateNote { get; set; }
public int StageId { get; set; }
public string UsernameVotant { get; set; }
public string UsernameEvaluate { get; set; }
public int Note { get; set; }
public int NoteAccueil { get; set; }
public double NotePedagogie { get; set; }
public double NoteRapportQP { get; set; }
public double NoteContenu { get; set; }
[SubSonicLongString]
public string Comment { get; set; } 
public bool IsValidate { get; set; }