I have two types:
public class DocumentEntityItem
{
public int Id { get; set; }
public string Type { get; set; }
}
public partial class DocumentEntityToFilesCategory
{
public int FilesCategoryId { get; set; }
public int CmsFileId { get; set; }
public Nullable<int> Sorder { get; set; }
public string DocumentType { get; set; }
public virtual FilesCategory FilesCategory { get; set; }
}
And I got the list of DocumentEntityToFilesCategory type. I want to exclude from this list another list of type DocumentEntityItem by two properties - CmsFileId and DocumentType, so I tried to write some code like:
List<string> mainList = new List<string>()
{
"1/document",
"1/link",
"2/document",
"3/link"
};
var documentToCategoryItems= DB.DocumentEntityToFilesCategory.Where(z => z.FilesCategoryId == categoryId);
List<DocumentEntityItem> documentEntityItems= mainList.Select(z => new DocumentEntityItem
{
Id = Int32.Parse(z.Split("/")[0]),
Type = z.Split("/")[1]
}).ToList();
var toDelete = documentToCategoryItems.Where(z => !documentEntityItems.Any(c=>c.Id==z.CmsFileId&&c.Type==z.DocumentType));
But, List.Any() supports only primitive types.