2012-03-29 4 views
1

엔티티가 Azure 테이블에서 삭제되지 않음 Visual Studio는 "serviceContext.DeleteObject (entity);"행에서 충돌을 계속하고 "컨텍스트가 현재 엔티티를 추적하지 않습니다."라고 말합니다. 누구에게 어떤 아이디어가 있으며 왜 고쳐야합니까?엔티티를 삭제하려고 시도하면

CloudTableQuery<ScheduleEntity> query = scheduleManNot.retrieveSchedule(); 

      //Checks every entry 
      foreach (ScheduleEntity entity in query) 
      { 
       comparison = System.DateTime.Compare(entity.eventTime, time); 

       if (comparison <= 0) 
       { 
        changeConfirmation = scheduleManNot.changeInstanceCount(entity.subscriptionID, entity.amount, entity.serviceName); 

        if (changeConfirmation == false) 
        { 
         Console.WriteLine("Configuration Change failed"); 
        } 

        if (changeConfirmation == true) 
        { 

         Console.WriteLine("Configuration Change Succeeded"); 
         Console.WriteLine(entity.serviceName + " had its instance count changed to " + entity.amount); 


         serviceContext.AttachTo("schedule", entity, "*"); 
         serviceContext.DeleteObject(entity); 

         //Submit the operation to the table service 
         serviceContext.SaveChangesWithRetries(); 

답변

1

쿼리를 통해 엔터티를 수신 중이기 때문에 엔터티를 연결할 필요가 없습니다. 그래서 나는 여기 코멘트에서 언급 한 것처럼 attachto가 전혀 필요 없다고 생각합니다. 첨부되지 않은 항목을 삭제해야하는 경우 먼저 첨부하고 삭제 된 것으로 표시 할 수 있습니다.

+0

내가 확인하고 "일정"이 올바른 데이터 집합입니다. 솔직히 말해서 나는 정확하게 AttachTo가 작동하는 방법을 잘 알고 있습니다. 다른 곳에서는 객체를 삭제할 필요가 없습니다. – StevenR

+0

답변을 업데이트했습니다. – daryal

+0

attachTo를 꺼내면서도 여전히 동일한 오류가 발생했습니다 – StevenR

관련 문제