SubSonic 3:如何链接类别/表格?
在使用 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);
}
While using SubSonic 3 I wrote the below. I thought I would get user_ref would be a column with name_list as its foreign key. My database ended up with just id and link with only the image_list table.
How can I have user_ref use name_list as its foreign key and have both tables in the database?
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);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SimpleRepository 根本无法构建外键:它不在数据库中放入任何逻辑,只是数据。如果需要外键,则需要先构建数据库,然后使用 ActiveRecord 或 LINQ 模板...
The SimpleRepository can't build foreign keys at all: it puts no logic in the DB, just data. If you want foreign keys, you need to build the db first, and use ActiveRecord or the LINQ templates...