【问题标题】:SubSonic 3: How do I link class/tables?SubSonic 3:如何链接类/表?
【发布时间】:2009-12-23 14:06:21
【问题描述】:

在使用 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);
}

【问题讨论】:

    标签: foreign-keys subsonic3


    【解决方案1】:

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

    【讨论】:

    • 那么就没有办法建数据库了吗?是自己动手还是自己写sql代码?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多