Comparing two objects to check whether they are different
<p>I have a method that accepts two parameters. Projecthealthnotes is my model. </p>

<p>I will like to compare objprojHealth with the getRow object that I am retrieving from the database.</p>

<p>If they are the same no need to call SaveChanges() and if not the same then call SaveChanges()</p>

<p>How can I compare these two objects and check whether they are the same?</p>

<pre><code>            public string WriteProgressHealthInfoToDb(Projecthealthnotes objprojHealth, string typeOfOperation)
                    {
                        using (var dbCntxt = new PPMSEntities1())
                        {

                                tbl_Project_Status_MSTR psmTable;               
                                var convertedId = Convert.ToInt64(objprojHealth.Id);
                                var getRow = dbCntxt.tbl_Project_Status_MSTR.Single(m =&gt; m.ProjectStatusID == convertedId);

                                getRow.RecentProgress = objprojHealth.Recentprogress;
                                getRow.ObstaclesRisks = objprojHealth.Obstaclesrisk;
                                getRow.NextSteps = objprojHealth.Nextsteps;
                                getRow.ForWeekEnding = Convert.ToDateTime(objprojHealth.Weekendingdate);
                                getRow.BudgetHealth = Translator(objprojHealth.BudgetHealth);
                                getRow.TeamHealth = Translator(objprojHealth.TeamHealth);
                                getRow.RiskHealth = Translator(objprojHealth.RiskHealth);
                                getRow.ArtifactHealth = Translator(objprojHealth.BenefitHealth);
                                getRow.ScopeHealth = Translator(objprojHealth.ScopeHealth);
                                getRow.ScheduleHealth = Translator(objprojHealth.ScheduleHealth);
                                getRow.Phase = objprojHealth.Phase;
                                getRow.ReportingPeriod = Convert.ToInt16(objprojHealth.Reportingperiod);

                                //dbCntxt.Entry(getRow).State = System.Data.Entity.EntityState.Modified;

                                dbCntxt.SaveChanges();

                            return "success";

                        }
</code></pre>