Compare-Net-Objects icon indicating copy to clipboard operation
Compare-Net-Objects copied to clipboard

Problem solved: Dictionary with Enum as Key

Open NeoCSharp opened this issue 1 year ago • 1 comments

Comparing a Dictionary with Enum as key the PropertyPath will not result in something like [EnumName].Value.MyProperty instead it will result in Value.MyProperty because ShouldCompareByKeys will return false. Enum is not a simple type even if it is a integer or similar.

NeoCSharp avatar Jul 11 '24 21:07 NeoCSharp

I am no longer the owner of this repository. You will need to contact Kellerman Software.

GregFinzer avatar Jul 12 '24 18:07 GregFinzer

in DataRowComparer.cs

if (dataRow1.IsNull(i)) { Difference difference = new Difference { ParentObject1 = parms.ParentObject1, ParentObject2 = parms.ParentObject2, PropertyName = currentBreadCrumb, Object1Value = "(null)", Object2Value = NiceString(dataRow2[i]), Object1 = parms.Object1, Object2 = parms.Object2 };

  AddDifference(parms.Result, difference);
  //return;
 //It may be necessary to change 'return' to 'continue', otherwise other differences will be ignored
  continue;

}

if (dataRow2.IsNull(i)) { Difference difference = new Difference { ParentObject1 = parms.ParentObject1, ParentObject2 = parms.ParentObject2, PropertyName = currentBreadCrumb, Object1Value = NiceString(dataRow1[i]), Object2Value = "(null)", Object1 = parms.Object1, Object2 = parms.Object2 };

  AddDifference(parms.Result, difference);
  //return;
 //It may be necessary to change 'return' to 'continue', otherwise other differences will be ignored
  continue;

}

lqp168 avatar May 14 '25 05:05 lqp168