C#C
C#3y ago
Dropps

✅ System.NotSupportedException with EF Core

quick question:

public async Task<List<Order>> GetAllOrders()
    {
        return await _dbContext.Orders
            .Include(o => o.OrderFoods!)
            .ThenInclude(of => of.Food)
            .ToListAsync();
    }

gives me a NotSupportedException but how do i fix that?

dataclass:
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

#pragma warning disable CS8618
namespace iFoodTracker.Models;

public class Order
{
    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public Guid Id { get; set; }
    public DateTime CreatedAt { get; set; }
    public bool PaidStatus { get; set; }
    public string UserId { get; set; }
    public string? EmployeeShort { get; set; }
    public IEnumerable<OrderFood>? OrderFoods { get; set; }
}
Was this page helpful?