SubSonic 3:如何链接班级/表格?

时间:2009-12-23 14:06:22

标签: foreign-keys subsonic3

使用SubSonic 3时,我写了以下内容。我以为我会得到user_ref将是一个name_list作为其外键的列。我的数据库最终只有id和链接,只有image_list表。

如何让user_ref使用name_list作为其外键并在数据库中同时拥有这两个表?

class image_list
{
    public long ID { get; set; }
    public name_list user_ref{ get; set; } 
    public string link{ get; set; } 
}
class name_list
{
    public long ID;
    public string username;
}


{
    var a = new image_list();
    a.link = "link";
    a.user_ref = new name_list();
    a.user_ref.username = "name";
    repo.Add(a);
}

1 个答案:

答案 0 :(得分:1)

SimpleRepository can't build foreign keys at all:它没有在数据库just data中放置逻辑。如果你想要外键,你需要先建立数据库,然后使用ActiveRecordLINQ templates ......