我不完全确定这个问题的标题是什么,这是我要解决的问题。
我有两张表,它们之间存在多对多关系,Fight 和 Fighter。一个战士可以参加很多战斗,一个战斗有很多战士(2个战士)。这些映射得很好,但我想做的是在战斗表中有一个列,我可以在其中设置谁赢得了两个战士之间的战斗。最好的方法是什么?
在此先感谢您,如果您不明白,我会尝试以更好的方式进行解释。
public class Fight
{
[Key]
public int FightId { get; set; }
[Key, ForeignKey("FightCard")]
public int CardId { get; set; }
public virtual ICollection<Fighter> Fighters { get; set; }
}
public class Fighter
{
[Key]
public int FighterID { get; set; }
[Required]
[DisplayName("First Name")]
public string FirstName { get; set; }
[Required]
[DisplayName("Last Name")]
public string LastName { get; set; }
[DisplayName("Nickname")]
public string NickName { get; set; }
[Required]
public string Nationality { get; set; }
public static String[] WeightClassOptions
{
get
{
return new String[] { "Heavyweight", "Light Heavyweight", "Middleweight", "Welterweight", "Lightweight", "Featherweight", "Bantamweight", "Flyweight" };
}
}
[DisplayName("Weight Class")]
public string WeightClass { get; set; }
public string Height { get; set; }
[Required]
[DisplayName("Date of Birth")]
[DataType(DataType.Date)]
public DateTime DateOfBirth { get; set; }
// Fight Record:
public int Wins { get; set; }
public int Loss { get; set; }
public int Draw { get; set; }
public int NoContest { get; set; }
public String Picture { get; set; }
public virtual ICollection<Fight> Fight { get; set; }