2016-10-11 6 views
0

두 개의 매개 변수를 허용하는 메서드가 있습니다. Projecthealthnotes가 제 모델입니다.두 개체를 비교하여 서로 다른지 확인합니다

objprojHealth와 데이터베이스에서 가져 오는 getRow 개체를 비교하고 싶습니다.

그들은 같은 다음 전화 SaveChanges를()

가 어떻게이 두 개체를 비교하고는 동일한 여부를 확인할 수 있습니다 SaveChanges를을 (호출 할 필요 같은)와 그렇지 않은 경우가 있다면?

  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 => 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"; 

         } 

답변