I have a list from a customer class that is shown below
internal class RMDocument
{
public string FolderProfileNumber { get; set; }
public string FolderName { get; set; }
public List<FolderItem> Documents { get; set; }
}
and as you see, there is a list from FolderItem. and FolderItem has DocNumber property.
so I want to delete item which has the same document number with Documents items.
foreach (var dup in DocumentsAndParents.Where(d => !(d.Value.Count == 1 && d.Value[0].ReferenceCount == 1)))
{
var duplicated = ExportDocumentsToRm.SelectMany(s =>
s.Documents).FirstOrDefault(f => f.DocNumber.Equals(dup.Key));
if (duplicated != null)
{
ExportDocumentsToRm.SelectMany(s => s.Documents).ToList()
.RemoveAll(r => r.DocNumber.Equals(duplicated.DocNumber));
}
}
with code I think my question is clear. Well I know the problem, I used ToList() thats why it doesnt remove, but otherwise I cant access RemoveAll or other Remove methods.
How I can remove items if docnumber is the same with anitem from Documents. I just want to remove item from the "Documents" not from the ExportDocumentsToRm, It has Documents property as a list