未创建列

发布于 2024-08-17 05:53:22 字数 1456 浏览 3 评论 0原文

我在我的新项目中使用 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...) ->作品 评论=“” isValidate = false


当我注意到将列命名为“Read”时出现问题,我尝试重命名列,重命名表(即“Vote”[法语]),但问题与我的原始表“Votes”相同“

你能帮我一下吗?

预先感谢(抱歉我的英语)

I'm using Subsonic (SimpleRepository) in my new project and enjoy using it but...

With one, and only one of my table, it does not create all the columns and i don't understand why.

Here is the code :

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; }
}

Called like my other classes :

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

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

The table Ratings created contains the columns :
ID, Comment, isValidate

Whatever what I try to add as default value, the 3 columns contains the value :
ID = 1 (2, 3, 4...) -> works
Comment = ""
isValidate = false


As i noticed a probleme where naming a column "Read", i tryed to rename the columns, rename the table (which was "Vote" [in french]) but the probleme is the same as with my original table "Votes"

Could you help me please.

Thanks in advance (and sorry for my english)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

太阳男子 2024-08-24 05:53:22

您在该类中定义的唯一属性是 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; }

The only properties you're defining in that class are ID, Comment and isValidate so these are the only columns SubSonic will generate. Change your fields to properties and SubSonic should create columns for them:

[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; }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文