[HttpGet("GetByRoster""GetPlayersByRoster/{championshipId}/{teamId}")]
public async Task<IEnumerable<Player>>Task<IEnumerable<Roster>> GetByRostersGetPlayersByRoster(long championshipId, long teamId)
{
var playersroster = await _context.PlayersRosters.Include(pr => pr.RostersPlayer)
.ThenIncludeInclude(r => r.Championship)
.Include(pr => pr.RostersTeam)
.ThenIncludeWhere(r => r.TeamChampionshipId == championshipId && r.TeamId == teamId)
.ToListAsync();
return roster;
}
Estas son las clases involucradas.
public class Championship
{
[Key]
public long Id { get; set; }
[Required]
[MaxLength(200)]
public required string Identifier { get; set; }
[Required]
public DateTime StartDate { get; set; }
public DateTime? EndDate { get; set; }
[Required]
public required bool InProgress { get; set; }
public long? FederationId { get; set; }
public long? AssociationId { get; set; }
public long? LeagueId { get; set; }
public required long CategoryId { get; set; }
[ForeignKey("FederationId")]
public Federation? Federation { get; set; }
[ForeignKey("AssociationId")]
public Association? Association { get; set; }
[ForeignKey("LeagueId")]
public League? League { get; set; }
[ForeignKey("CategoryId")]
public Category? Category { get; set; }
public List<Roster>? Rosters { get; set; }
public List<ChampionshipSponsor>? ChampionshipSponsors { get; set; }
public List<ChampionshipCondition>? ChampionshipConditions { get; set; }
public List<ChampionshipTeam>? ChampionshipTeams { get; set; }
public DateTime? CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
}
public class Roster
{
[Key]
public long Id { get; set; }
[Required]
public DateTime SaveDate { get; set; }
[Required]
public bool IsActive { get; set; }
[Required]
[MaxLength(15)]
public required string UniformNumber { get; set; }
[Required]
public long ChampionshipId { get; set; }
[Required]
public long TeamId { get; set; }
[Required]
public long PlayerId { get; set; }
[ForeignKey("ChampionshipId")]
public Championship? Championship { get; set; }
[ForeignKey("TeamId")]
public Team? Team { get; set; }
[ForeignKey("PlayerId")]
public Player? Player { get; set; }
public List<OffensiveStat>? OffensiveStats { get; set; }
public List<PitchingStat>? PitchingStats { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
}
public class Player
{
[Key]
public long Id { get; set; }
[Required]
[MaxLength(200)]
public required string Dni { get; set; }
[Required]
[MaxLength(200)]
public required string FirstName { get; set; }
[Required]
[MaxLength(200)]
public required string SecondName { get; set; }
[Required]
[MaxLength(200)]
public required string Surname { get; set; }
[Required]
[MaxLength(200)]
public required string SecondSurname { get; set; }
[Required]
public DateTime BirthDate { get; set; }
[Required]
[MaxLength(10)]
public required string Gender { get; set; }
public List<Roster>? Rosters { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
}
public class Team
{
[Key]
public long Id { get; set; }
[Required]
[MaxLength(200)]
public required string Name { get; set; }
public List<Roster>? Rosters { get; set; }
public List<AssociationTeam>? AssociationsTeams { get; set; }
public List<TeamCategory>? TeamCategories { get; set; }
public List<FederationTeam>? FederationTeams { get; set; }
public List<LeagueTeam>? LeagueTeams { get; set; }
public List<ChampionshipTeam>? ChampionshipTeams { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
}
Este es el erro que me arroja cuando intento hacer la consulta