SubSonic 3 - 简单存储库 - 一对多关系
这是我第一次使用 Subsonic。
假设我有这些课程:
public class Store
{
public int Id { get; set; }
public String Name { get; set; }
}
public class Employee
{
public int Id { get; set; }
public String Name { get; set; }
}
一名员工与一家具有雇佣日期的商店相关。这意味着在数据库中我将有一个中间表,其中包含 StoreId、EmployeeId、StartDate、EndDate
UPDATE
员工可以从 2009-01-01 到 2009-04-04 为 StoreA 工作,从 2009-04-05 为 StoreB 工作......而且我不希望每次员工更换他工作的商店时我的数据表都会重复我的员工的所有信息。在这个例子中,员工只有一个名字,但假设一名员工有 10 项财产(地址、年龄、性别...)
我怎样才能实现这一点?
It's the first time I use Subsonic.
Let say I have those classes :
public class Store
{
public int Id { get; set; }
public String Name { get; set; }
}
public class Employee
{
public int Id { get; set; }
public String Name { get; set; }
}
An employee is related to a store with is hired date. This means that in the database I will have a middle table With StoreId, EmployeeId, StartDate, EndDate
UPDATE
An employee can work to the StoreA from 2009-01-01 to 2009-04-04 and work for StoreB from 2009-04-05 to ... And I don't want that my data table repeat all the information of my employee each time an employee change the store he working for. In this example employee have only a name, but lets say an employee got 10 property (adress, age, gender ...)
How could I achieve that ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您的评论和更新的问题,您似乎想要如下内容:
Based on your comment and the updated question it looks like you want something like the following:
您实际上需要一个多对多关系,它将员工记录连接到商店记录,并带有开始日期和结束日期的有效负载。
对象将如下所示:
徒手完成此操作,因此可能会出现一些错误。
You'll actually need a many-to-many relationship which will join an Employee record to a Store Record, with a payload of Start and End Dates.
The Objects will look like this:
Did this freehand so there could be a couple errors.