title: Getting Difference Between Two Objects With Same Properties
body: <p>I am trying get a list of the changes that were made to an Employee model (object 1) using an EmployeeHistory model (object 2). Basically, there is one single employee record but there are several EmployeeHistory records. Every time something is changed on an Employee a new record is added to the EmployeeHistory table which contains the data of the Employee prior to the change. I want a way to compare each of the EmployeeHistory Records and return a list of strings reporting the changes that were made. So in order to get the list of changes I want to iterate through the list of EmployeeHistory records and compare each EmployeeHistory Record with the previous EmployeeHistory record. And the very last EmployeeHistory record will need to be compared to the current Employee (object 1) record which is very similar in properties. Is there any way to do this without having an insane amount of IF statements  comparing the two properties on each of the records?</p>
  
  <p>This is kind of what I am looking for:</p>
  
  <pre><code> public List&lt;string&gt; GetEmployeeMasterHistory(Models.EmployeeMaster employee,IEnumerable&lt;EmployeeMasterHistory&gt; employeeHistoryCollection)
   {
         foreach (var historyRecord in employeeHistoryCollection)
         {
            //Compare historyRecord to EmployeeCollection[historyRecord.Index() - 1]
         }
         return null;
   }
  </code></pre>
  
  <p>I already have a method that does all the check for each of the properties but there is going to be a lot more properties added in the future and I tired of having to add the new IF statements and it doesn't seem very efficient.</p>
  
  <p>Here is what a EmployeeMasterHistory Record looks like:</p>
  
  <pre><code> public partial class EmployeeMasterHistory
      {
          public Nullable&lt;int&gt; EmployeeNumber { get; set; }
          public Nullable&lt;int&gt; CompanyNumber { get; set; }
          public string UserName { get; set; }
          public string Initials { get; set; }
          public string FirstName { get; set; }
          public string LastName { get; set; }
          public string FullName { get; set; }
          public Nullable&lt;bool&gt; StatusFlag { get; set; }
          public Nullable&lt;System.DateTime&gt; StartDate { get; set; }
          public Nullable&lt;System.DateTime&gt; TerminationDate { get; set; }
          public string Branch { get; set; }
          public Nullable&lt;int&gt; DepartmentNumber { get; set; }
          public string Supervisor { get; set; }
          public Nullable&lt;int&gt; Shift { get; set; }
          public Nullable&lt;int&gt; UnionNo { get; set; }
          public string G2ID { get; set; }
          public Nullable&lt;bool&gt; EnterTimeFl { get; set; }
          public string Phone { get; set; }
          public string Extension { get; set; }
          public string CellPhone { get; set; }
          public string Email { get; set; }
          public Nullable&lt;int&gt; PrimaryJobRole { get; set; }
          public Nullable&lt;int&gt; JobLevel { get; set; }
          public Nullable&lt;int&gt; JobGroup { get; set; }
          public string JobTitle { get; set; }
          public string EmployeeType { get; set; }
          public string PayType { get; set; }
          public Nullable&lt;decimal&gt; Rate { get; set; }
          public Nullable&lt;System.DateTime&gt; LastReviewDate { get; set; }
          public Nullable&lt;System.DateTime&gt; NextReviewDate { get; set; }
          public Nullable&lt;System.DateTime&gt; LastPayChangeDate { get; set; }
          public string EmergencyContact { get; set; }
          public string EmergencyContactRelationship { get; set; }
          public string EmergencyContactPhone { get; set; }
          public Nullable&lt;bool&gt; CPComputer { get; set; }
          public Nullable&lt;bool&gt; CPPhone { get; set; }
          public Nullable&lt;bool&gt; CPCreditCard { get; set; }
          public Nullable&lt;bool&gt; CPGasCard { get; set; }
          public Nullable&lt;bool&gt; CPKeys { get; set; }
          public Nullable&lt;bool&gt; CPSecurityCard { get; set; }
          public Nullable&lt;bool&gt; CPVehicle { get; set; }
          public Nullable&lt;bool&gt; CPTools { get; set; }
          public Nullable&lt;bool&gt; CPUniform { get; set; }
          public string ModBy { get; set; }
          public Nullable&lt;System.DateTime&gt; ModDate { get; set; }
          public int ID { get; set; }
          public string SalesRep { get; set; }
          public string MiddleName { get; set; }
          public Nullable&lt;int&gt; ManagerEmpNo { get; set; }
          public Nullable&lt;bool&gt; TempFl { get; set; }
          public Nullable&lt;bool&gt; PEWFl { get; set; }
          public Nullable&lt;bool&gt; PGTFl { get; set; }
          public Nullable&lt;bool&gt; PMPFl { get; set; }
          public Nullable&lt;bool&gt; PPGEFl { get; set; }
          public Nullable&lt;bool&gt; PPGFl { get; set; }
          public Nullable&lt;bool&gt; PRCFl { get; set; }
          public Nullable&lt;bool&gt; PTCFl { get; set; }
          public Nullable&lt;bool&gt; PPFl { get; set; }
          public Nullable&lt;bool&gt; SWPFl { get; set; }
          public Nullable&lt;int&gt; PrimaryDivision { get; set; }
          public string TechGroupID { get; set; }
          public string TechLevelID { get; set; }
          public Nullable&lt;bool&gt; TechATD { get; set; }
          public Nullable&lt;int&gt; ReviewPeriod { get; set; }
          public Nullable&lt;bool&gt; CorpFl { get; set; }
      }
  </code></pre>
  
  <p>Thank you in advance!</p>