I have the following Entity classes:
public class History : BaseEntity { public string Version { get; set; } public DateTime? ReleaseDate { get; set; } public string Name { get; set; } public string Additional { get; set; } public List<HistoryEntry> Entries { get; set; } } public class HistoryEntry : BaseEntity { public string Version { get; set; } public string BugNr { get; set; } public AllowedTypes EntryType { get; set; } public string Description { get; set; } public History Parent { get; set; } } public enum AllowedTypes { Bug, Enhancement } which are mapped that way:
public HistoryMap() { ToTable("History"); HasKey(c => c.Version); Property(c => c.Version).HasMaxLength(10); Property(c => c.Name).HasMaxLength(200); } this results in two tables that act exactly like I wanted ("History" has "Version" as primary key and "HistoryEntry" has a foreign Key "Version" that is linked to "History"."Version"
After Adding some stuff into these tables I try to read the contents:
IQueryable<History> query = _historyRepository.Table.OrderByDescending(c => c.ReleaseDate); var historyList = new List<Core.Domain.Tengo.History>(query); While all History-Entries are read successfully, the "Entries"-Property if the "History"-Object is always NULL.
How do I achieve that the linked Items are also read and stored into Entries?
virtualaspublic virtual List<HistoryEntry> Entries { get; set; }