0
我正在创建一个自定义员工模块。一名员工最多可以有三个地址。我试图关注这篇文章 - http://docs.orchardproject.net/Documentation/Creating-1-n-and-n-n-relations将多个地址附加到一个员工
这就是我在Migrations.cs中所拥有的。
SchemaBuilder.CreateTable("EmployeeRecord",
table => table
.ContentPartRecord()
.Column<int>("EmployeeId")
...
.Column<int>("AddressRecord_Id")
);
SchemaBuilder.CreateTable("AddressRecord",
table => table
.Column<int>("Id", column => column.PrimaryKey().Identity())
...
);
这里是模型。
public class EmployeeRecord : ContentPartRecord {
public virtual int EmployeeId { get; set; }
...
public virtual AddressRecord AddressRecord { get; set; }
}
public class AddressRecord {
public virtual int Id { get; set; }
...
}
当提交create-new-employee表单时,我得到具有多个地址的数据。我可以创建一个新的员工内容类型。但我不知道如何创建这三个地址并将其分配给该员工。 有什么帮助吗?
谢谢。
我没在考虑底层的数据库设计。我试图尽可能密切关注这篇文章。在Orchard实施1-n关系还有其他的例子吗?上述链接中的地址/状态示例并不十分有用。 – user471317 2012-05-03 00:31:37
那么,这不是紧跟着这篇文章,因为你看到你的关系是向后的,而文章是正确的。你能解释一下这篇文章如何帮助我,让我知道你在期待什么? – 2012-05-03 04:06:25
该文章不容易遵循,地址/国家不是1-n关系的好例子。这是我在文章中看到的,AddressPartRecord有StateRecord,AddressPartRecord表有StateRecord_Id。 'code' public class AddressPartRecord:ContentPartRecord { ... public virtual StateRecord StateRecord {get;组; } ... } SchemaBuilder.CreateTable( “AddressPartRecord”, 表=>表 ... .COLUMN( “StateRecord_Id”) ... ); '代码' –
user471317
2012-05-03 17:21:27