I am working on a repository method in Entity Framework Core to retrieve all applications along with their associated application tokens. My method looks like this:
Код: Выделить всё
public async Task GetAllApplications(string? expand = null) { List applications = await context.Applications.Include(a => a.ApplicationTokens).ToListAsync(); return mapper.Map(applications); }
Код: Выделить всё
.ThenInclude(t => t.Application)
Код: Выделить всё
public class Application { public int Id { get; set; } public required string Name { get; set; } public required string Description { get; set; } public DateTime CreatedAt { get; set; } public required int CreatedById { get; set; } public User? CreatedBy { get; set; } public ICollection? ApplicationTokens { get; set; } public ICollection? FeatureGates { get; set; } } public class ApplicationToken { public int Id { get; set; } public required int ApplicationId { get; set; } public required string Token { get; set; } public required bool Enabled { get; set; } public required DateTime CreatedAt { get; set; } public required int CreatedById { get; set; } public required DateTime ExpiresAt { get; set; } public Application? Application { get; set; } public User? CreatedBy { get; set; } }
What am I missing here?
Источник: https://stackoverflow.com/questions/781 ... g-data-wit