【发布时间】:2013-02-04 15:29:18
【问题描述】:
我有“用户”和“出价”模型。
当然还有 DateBase 中的“Users”和“Bids”表。 ("Bid" columns in postgres table)
我可以像这样映射一个“用户”字段:
public int UserId { get; set; }
public virtual User User { get; set; }
但不知道如何映射三个具有不同名称的“用户”字段。
public int CreatorId { get; set; }//id of user in db table
public int ManagerId { get; set; }//id of user in db table
public int ExecutorId { get; set; }//id of user in db table
public virtual User Creator { get; set; }
public virtual User Manager { get; set; }
public virtual User Executor { get; set; }
我该怎么办?
public class Bid
{
public int BidId { get; set; }
public string Title { get; set; }
public string Text { get; set; }
public DateTime DateOfCreating { get; set; }
public DateTime DateOfProcessing { get; set; }
public DateTime DateOfExecution { get; set; }
//here is something incorrect
public int CreatorId { get; set; }
public int ManagerId { get; set; }
public int ExecutorId { get; set; }
public virtual User Creator { get; set; }
public virtual User Manager { get; set; }
public virtual User Executor { get; set; }
public bool IsProcessed { get; set; }
public bool IsExecuted { get; set; }
public bool IsExecutionConfirmed { get; set; }
}
【问题讨论】:
-
不知道你问的是什么人!你想让它做什么?
-
为什么不正确?
-
试着更清楚你的要求,希望你投票旁边的负面标志会消失。如果你问我认为你在问什么,你应该能够在你的 OnModelCreating 方法中在你的上下文中使用流利的 API 来指定它。
-
语言能力差。我会更认真地学习英语。
标签: c# entity-framework postgresql ef-code-first