I have this code to compare two objects, these two out put results are same. but my equal condition is allways getting false. I am not understanding is that something I am doign wrong here?
var t1 = repo.Model_Test_ViewAllBenefitCodes(2).OrderBy(p => p.ba_Object_id).ToArray();//.FirstOrDefault();
var t2 = x.ViewAllBenefitCodes.OrderBy(p => p.ba_Object_id).ToArray();//.FirstOrDefault();
for (int i = 0; i < t1.Count(); i++)
{
var res1 = t1[i]==(t2[i]);
var res = t1[i].Equals(t2[i]);
Assert.AreEqual(res, true);
}
It really depends on the object you’re trying to compare, but this will compare classes that only have children (no grandchildren?) It’s using reflection to pull all of the properties in the class and compare them.