I have a domain class like this:
public class DomainClass
{
public virtual string name{get;set;}
public virtual IList Notes{get;set;}
}
>
Edit2: This method doesn't require casting to a List
!
foreach (var n in Notes.Where(note => note.Id == id).ToArray()) Notes.Remove(n);
or...
Notes.Remove(Notes.Where(note => note.Id == id).First());
The first one is the best.
The second one will throw an exception if no notes have that id
.
Edit: Thanks to Magnus and rsbarro for showing my mistake.