C#C
C#2y ago
stepa

need help with ef

var recordsToSkip = (_filmsPageIndex - 1) * 10;
IQueryable<Film> query = _context.Films
    .Include(u => u.Janr)
    .Include(u => u.Zal)
    .Include(u => u.Actors)
    .OrderByDescending(x => x.Id);


if (FilmActorText.Length != 0)
{
    query = query.Where(x => x.Actors != null && x.Actors.Any(actor => EF.Functions.Like(actor.Name, $"{FilmActorText}%")));
}

_films = query.Skip(recordsToSkip)
            .Take(10)
            .ToList();

public class Film
{
    [Key]
    public int Id { get; set; }
    ...
    public List<Actor>? Actors { get; set; }
}

public class Actor
{
    [Key]
    public int Id { get; set; }
    public required string Name { get; set; }
    [Browsable(false)]
    public List<Film>? Films { get; set; }
}

There is exception
I’ll send the exception text in 5 minutes, it doesn’t fit into the limit

How do I fix it?
Was this page helpful?