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; }
}
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
4 replies