© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
3 replies
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);
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}%")));
}
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();
_films = query.Skip(recordsToSkip)
            .Take(10)
            .ToList();

public class Film
{
    [Key]
    public int Id { get; set; }
    ...
    public List<Actor>? Actors { get; set; }
}
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; }
}
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
I’ll send the exception text in 5 minutes, it doesn’t fit into the limit

How do I fix it?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Need help with EF 6 Migrations
C#CC# / help
3y ago
Ef core help
C#CC# / help
10mo ago
Help! records & Ef
C#CC# / help
2y ago
Help with EF Core polymorphic associations
C#CC# / help
2y ago