المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Linq - Remove Object From Collection



C# Programming
12-08-2011, 11:40 PM
I have a list of these models:

public class NodeModel : ViewModelBase { public Guid Id { get; set; } public string Caption { get; set; } public string Description { get; set; } public bool IsActive { get; set; } public int Sequence { get; set; } public ImageSource Image { get; set; } public bool IsExpanded { get; set; } public string FileName { get; set; } public NodeType Type { get; set; } public List Children { get; set; } public NodeModel() { Children = new List(); FileName = string.Empty; } }
The list is contained in a collection called Folders. I want to remove an object from the collection, so I'm using:

Folders.Remove(f => f.Id == model.Id);
But it's not removing it, What's wrong here?
Everything makes sense in someone's mind