public void SaveFilmsFromWeb(WebFilmClass webFilmClass) { var p = webFilmClass.results.Select(x => new Film { adult = x.adult, backdrop_path = x.backdrop_path, genre_ids = string.Join(",", x.genre_ids.ToArray()), Id = x.id, original_language = x.original_language, original_title = x.original_title, overview = x.overview, popularity = (decimal)x.popularity, poster_path = x.poster_path, release_date = x.release_date, title = x.title, video = x.video, vote_average = (decimal)x.vote_average, vote_count = x.vote_count } ).ToList(); var all = _filmRepository.GetAll(); var distinct = p.Where(l2 => all.All(l1 => l1.Id != l2.Id)).ToList(); _filmRepository.AddRange(distinct); var same = p.Where(l2 => all.Any(l1 => l1.Id == l2.Id)).ToList(); _filmRepository.Update(same); }