I have a domain class like this:
public class DomainClass
{
public virtual string name{get;set;}
public virtual IList Notes{get;set;}
}
>
If you can change the datastructure I would suggest using a Dictionary
. Than you can go with:
public class DomainClass
{
public virtual string name{get;set;}
public virtual IDictionary Notes {get; set;}
//Helper property to get the notes in the dictionary
public IEnumerable AllNotes
{
get
{
return notes.Select (n => n.Value);
}
}
public virtual void RemoveNote(int id)
{
Notes.Remove(id);
}
}
If ID is not unique use IDictionary
instead.