I am trying to distinguish between the two collections.
private ObservableCollection<SomeObject> _objectList = null; private ObservableCollection<SomeObject> _cachedObjectList = null;
SomeObject implements IEquatable<SomeObject>
I use the following to determine if I have two collections:
this._objectList.ToList().OrderBy(x => x.Id).SequenceEqual(this._cachedObjectList.ToList().OrderBy(x => x.Id));
- The _cachedObjectList collection will not change.
- You can add, delete or modify an object in the _objectList collection.
How can I return a new list containing a new added, deleted or modified object from two collections.
Any help would be greatly appreciated!
Implementation of IEquatable for SomeObject:
public class SomeObject : IEquatable<SomeObject> { public int GetHashCode(SomeObject object) { return base.GetHashCode(); } public bool Equals(SomeObject other) { bool result = true; if (Object.ReferenceEquals(other, null)) { result = false; }
EDIT: I need changes only if _objectList contains a modified object based on IEquatable.Equals (), after which I would like to return it. Otherwise, return new objects or deleted objects to the list.
source share