Cannot compare collections with items of different types
See original GitHub issueThe library doesn’t work correctly in case when you compare lists with items of different types. You are getting an exception like the following:
System.Exception : Invalid CollectionMatchingSpec. No such property XXXXProperty for type YYYYYClass
at KellermanSoftware.CompareNetObjects.IgnoreOrderTypes.IgnoreOrderLogic.GetMatchIndex(ComparisonResult result, List`1 spec, Object currentObject)
at KellermanSoftware.CompareNetObjects.IgnoreOrderTypes.IgnoreOrderLogic.CompareInOrder(CompareParms parms)
at KellermanSoftware.CompareNetObjects.IgnoreOrderTypes.IgnoreOrderLogic.CompareEnumeratorIgnoreOrder(CompareParms parms, Boolean countsDifferent)
at KellermanSoftware.CompareNetObjects.TypeComparers.ListComparer.CompareType(CompareParms parms)
at KellermanSoftware.CompareNetObjects.RootComparer.Compare(CompareParms parms)
at KellermanSoftware.CompareNetObjects.TypeComparers.PropertyComparer.PerformCompareProperties(CompareParms parms)
at KellermanSoftware.CompareNetObjects.TypeComparers.ClassComparer.CompareType(CompareParms parms)
at KellermanSoftware.CompareNetObjects.RootComparer.Compare(CompareParms parms)
at KellermanSoftware.CompareNetObjects.IgnoreOrderTypes.IgnoreOrderLogic.CompareInOrder(CompareParms parms)
at KellermanSoftware.CompareNetObjects.IgnoreOrderTypes.IgnoreOrderLogic.CompareEnumeratorIgnoreOrder(CompareParms parms, Boolean countsDifferent)
at KellermanSoftware.CompareNetObjects.TypeComparers.ListComparer.CompareType(CompareParms parms)
at KellermanSoftware.CompareNetObjects.RootComparer.Compare(CompareParms parms)
at KellermanSoftware.CompareNetObjects.CompareLogic.Compare(Object object1, Object object2)
If you set IgnoreCollectionOrder = true it works better but in some situations you also receive the exception below.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
c# - Cannot compare elements of type 'System.Collections. ...
Cannot compare elements of type 'System.Collections.Generic.ICollection`1 Only primitive types, enumeration types and entity types are supported.
Read more >Compare-Object (Microsoft.PowerShell.Utility)
The Compare-Object cmdlet compares two sets of objects. One set of objects is the reference, and the other set of objects is the...
Read more >5 PL/SQL Collections and Records - Database
PL/SQL lets you define two kinds of composite data types: collection and record. ... You cannot compare associative array variables to the value...
Read more >C# – Cannot compare elements of type 'System.Collections ...
C# – Cannot compare elements of type 'System.Collections.Generic.ICollection`1 Only primitive types, enumeration types and entity types are supported.
Read more >Cannot compare incompatible operands of type List ...
Hi ,. How can I overcome this error. Expression evaluation error : Cannot compare incompatible operands of type List of Variant and type...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

You will need to specify a collection matching spec for both types:
@PalashBansal Sorry the Compare .NET Object Library is not going to work for something like this. You will need to write your own comparison code.