-
-
Notifications
You must be signed in to change notification settings - Fork 197
Comparing Lists of Different Lengths
GregFinzer edited this page Dec 20, 2017
·
4 revisions
Sometimes lists, arrays, and dictionaries are equal to each other but they are in a different order. The Config.IgnoreCollectionOrder property can be used to compare lists that are not only out of order but also of different lengths. There is a huge performance decrease when Ignoring the Collection Order. This may be okay if you are comparing a few hundred objects at a time. By default all the simple type properties are used as a key for an object. To minimize the performance impact, define a Config.CollectionMatchingSpec. This defines the key for the object.
Example
CompareLogic logic = new CompareLogic();
logic.Config.IgnoreCollectionOrder = true;
var spec = new Dictionary<Type, IEnumerable<string>>();
spec.Add(typeof(Customer), new string[] { "CustomerId" });
logic.Config.CollectionMatchingSpec = spec;