I have two tables Round and Game. A round has many games, and I'd like to get all of the games of a round using a Web API.
Here are my classes (simplified for the sake of this question)
namespace DataLayer.Entities
{
[Table("Games")]
public class Game : IEntity
{
public Guid Id { get; set; }
public int PlayerOneId { get; set; }
public int PlayerTwoId { get; set; }
public Guid RoundId { get; set; }
[ForeignKey("RoundId")]
public Round Parent { get; set; }
}
}
namespace DataLayer.Entities
{
[Table("Rounds")]
public class Round
{
public ICollection<Game> Games { get; set; }
public Guid Id { get; set; }
public bool HasStarted { get; set; }
public DateTime TimeStarted { get; set; }
public int RoundNumber { get; set; }
}
}
I'd like to be able to pass in a round ID using Entity Framework and get all of the Games from that round.