@@ -1931,16 +1931,18 @@ private void PurgeTitlesAndOverviews(ForeignEntityType foreignType, int foreignI
1931
1931
private async Task < bool > UpdateCompanies ( IEntityMetadata tmdbEntity , List < ProductionCompany > companies )
1932
1932
{
1933
1933
var existingXrefs = _xrefTmdbCompanyEntity . GetByTmdbEntityTypeAndID ( tmdbEntity . Type , tmdbEntity . Id )
1934
- . ToDictionary ( xref => xref . TmdbCompanyID ) ;
1934
+ . GroupBy ( xref => xref . TmdbCompanyID )
1935
+ . ToDictionary ( xref => xref . Key , groupBy => groupBy . ToList ( ) ) ;
1935
1936
var xrefsToAdd = 0 ;
1936
1937
var xrefsToSkip = new HashSet < int > ( ) ;
1937
1938
var xrefsToSave = new List < TMDB_Company_Entity > ( ) ;
1938
1939
var indexCounter = 0 ;
1939
1940
foreach ( var company in companies )
1940
1941
{
1941
1942
var currentIndex = indexCounter ++ ;
1942
- if ( existingXrefs . TryGetValue ( company . Id , out var existingXref ) )
1943
+ if ( existingXrefs . TryGetValue ( company . Id , out var existingXrefList ) )
1943
1944
{
1945
+ var existingXref = existingXrefList [ 0 ] ;
1944
1946
if ( existingXref . Ordering != currentIndex || existingXref . ReleasedAt != tmdbEntity . ReleasedAt )
1945
1947
{
1946
1948
existingXref . Ordering = currentIndex ;
@@ -1958,6 +1960,7 @@ private async Task<bool> UpdateCompanies(IEntityMetadata tmdbEntity, List<Produc
1958
1960
await UpdateCompany ( company ) ;
1959
1961
}
1960
1962
var xrefsToRemove = existingXrefs . Values
1963
+ . SelectMany ( xrefs => xrefs )
1961
1964
. ExceptBy ( xrefsToSkip , o => o . TMDB_Company_EntityID )
1962
1965
. ToList ( ) ;
1963
1966
0 commit comments