I'm migrating a custom list from SharePoint 2010 on-premises to SharePoint Online. The source list has content types enabled and two custom content types associated. When migrating the list, i need to compare the associated content types collections, and add to the destination list all missing content types from the source list.
Here's my code:
var srcCTs = srcList.ContentTypes; var destCTs = destList.ContentTypes; var missingCTs = srcList.ContentTypes.Where(ct => !(destList.ContentTypes.Select(dct => dct.<UniqueKey>).Contains(ct.<UniqueKey>)));
where UniqueKey should be a property with unique values. I cannot use properties "Id", "StringId" or "Name" because its values are not unique, so I think I must change the code (or at least the third row)...
How do I check if content type already exists in the destination list?
EDIT: I need to compare both Content Type Collections (srcCTs and destCTs) and extract the difference between them.