I would like to retrieve a list of Encounters for a Given Pokemon, as a Pokemon can be encountered in many places, so I've been trying many variants of
var currentPokemon = _context.Pokemon
.Where(mon => mon.Id == id)
.Include(mon => mon.Encounters)
.FirstOrDefault();
With the result being a Pokemon object with all of the relevant data, but only the FIRST encounter being retrieved and put into a collection resulting in this:
Looking at the database, there are about 20 encounters for caterpie, and I'd like access to all of them, but only ever just get the one.
What the Pokemon class looks like (irrelevant fields omitted):
[Table("pokemon")]
public partial class Pokemon {
public Pokemon()
{
Encounters = new HashSet<Encounters>();
}
[Column("id")]
public long Id { get; set; }
[Required]
[Column("identifier", TypeName = "VARCHAR(79)")]
public string Identifier { get; set; }
.
.
.
[InverseProperty("Pokemon")]
public virtual ICollection<Encounters> Encounters { get; set; }
}
What Encounters looks like:
public partial class Encounters {
.
.
.
[ForeignKey("PokemonId")]
[InverseProperty("Encounters")]
public virtual Pokemon Pokemon { get; set; }
}
Db data :
What am I misunderstanding here?