Get next / previous record in ASP.NET Core MVC using Dapper

you have a bug in your code

  .SkipWhile(i => i.movie_id != i.movie_id)

is always false, so you will always have all records minus one, instead of one record.

I assume that you have movie_id and you need the next larger id after this , so try this code

var nextID = _movieRepository.GetAll()
                             .OrderBy(i => i.movie_id)
                             .Where(i => i.movie_id > movie_Id )
                             .Select(i => i.movie_id)
                             .FirstOrDefault();

this query will return next movie_id after current movie_id