2011-10-28 10 views
2

MVVM 개념 및 엔티티 프레임 워크에서 실버 라이트 애플리케이션을 사용하고 값을 업데이트하는 데 문제가 있습니다. 내 문제를 자세히 설명해 드리겠습니다. 나는 3 개의 테이블 A, B, C를 말하고 있는데, 여기서 B는 A와 외래 키 관계가 있고 C는 B와 외래 키 관계가 있습니다.이 테이블을 아무 문제없이 저장할 수 있습니다. 보기를 사용하여 표를 바인딩하고 편집을 위해 값을 검색 할 수 있지만 데이터베이스에 대한 변경 사항을 업데이트 할 수는 없습니다. 처리되지 않은 오류 Silverlight 응용 프로그램 코드에서 : 4004
카테고리 : ManagedRuntimeError 메시지 : System.ServiceModel.DomainServices.Client.DomainOperationException : Update는이 오류 **제출 작업 확인 실패

메시지 얻고 있지만 는 제출을 조작은 유효성 검증에 실패했습니다. 정보를 더 확인하려면 EntitiesInError의 각 엔티티에 대해 Entity.ValidationErrors를 확인하십시오. System.ServiceModel.DomainServices.Client.DomainContext EN System.ServiceModel.DomainServices.Client.SubmitOperation.Complete (OperationErrorStatus errorStatus) KO System.ServiceModel.DomainServices.Client.OperationBase.Complete (예외 에러) KO. <> C_ DisplayClassb.b _3 (객체 )

**

여기

뷰 모델 클래스는 ..

public void Save(object obj) 
    { 
      _currentCustomer.ModifiedBy = App.CurrentUser; 
      _currentCustomer.ModifiedDateTime = System.DateTime.Now; 

      foreach (BizFramework.Web.Model.Address address in AddressCollection.ToList()) 
      { 
       string address1 = Convert.ToString(address.Address1); 
       if (address1 != null && address1.Trim()!="") 
       {       
        CVEReference = (from addref in _currentCustomer.CustomerVendorEmployeeReferences 
            where addref.CustomerID == _currentCustomer.CustomerID 
            select addref).SingleOrDefault(); 

        BizFramework.Web.Model.Address addressExists = (from rec in CVEReference.Addresses 
                    where rec.AddressTypeID == address.AddressTypeID 
                    select rec).SingleOrDefault(); 
        if (addressExists != null) 
        { 
         address.ModifiedBy = App.CurrentUser; 
         address.ModifiedDateTime = System.DateTime.Now; 
        } 
        else 
        { 
         address.AddressGuid = System.Guid.NewGuid(); 
         address.ApplicationOwner = App.CurrentUser; 
         address.CreatedBy = App.CurrentUser; 
         address.ModifiedBy = App.CurrentUser; 
         address.CreatedDateTime = System.DateTime.Now; 
         address.ModifiedDateTime = System.DateTime.Now; 

         CVEReference.Addresses.Add(address); 
        } 

       } 
       else 
       { 
        //_currentCustomer.Addresses.Remove(address); 
        AddressCollection.Remove(address); 
        //dcBusinessAccountingContext.Addresses.Remove(address); 
       } 
      }       

     dcBusinessAccountingContext.SubmitChanges(); 
    } 

//Setting Table A from the view like this 

_currentCustomer = (from CustomerAddress in dcBusinessAccountingContext.Customers 
            where CustomerAddress.CustomerID == AddrView.CustomerID 
            select CustomerAddress).SingleOrDefault(); 

는 _currentcustomer는 A의 엔티티 객체가

, CVEReference입니다 B의 엔티티 객체 인 AddrView는 Table View의 엔티티 세트이고 addresscollection은 C의 콜렉션입니다. 어디에서 잘못 되었는가 또는이 오류의 원인이 될 수 있는지 알 수 없습니다. 이 문제를 통해 나를 인도 해주십시오. 감사합니다.

+1

오류 메시지를 읽었습니까? *** 자세한 정보는 EntitiesInError의 각 엔티티에 대한 Entity.ValidationErrors를 검사하십시오. *** – Will

답변

2

오류는 유효성 검사 문제라고 말합니다. 이 당신을 도울 것입니다

private void SubmitCallback(SubmitOperation operation) 
{ 
     if (operation.HasError) 
     { 
      //check "operation.EntitiesInError" for more details. 
     } 
} 

희망 :

dcBusinessAccountingContext.SubmitChanges(SubmitCallback, null); 

dcBusinessAccountingContext.SubmitChanges();을 변경 것은 그럼 당신은 몇 가지 오류 검사를 할 수 있습니다.