Submit Operation Failed on Validation in Silverlight 4

Locked Submit Operation Failed on Validation in Silverlight 4

  • Wednesday, November 02, 2011 11:54 AM
     
      Has Code

    Hi,

       I am working with silver light application with MVVM Concept using Entity framework and having some trouble in updating the values. Let me elaborate my problem. I am having three tables say A, B, and C where B has the foreign key relationship with A and C has foreign key relationship with B. I could able to save these tables with out any problem. I am using a view to bind the grid and able to retrieve values for editing but unable to update any changes to the data base.

    While Update I am getting this error **

    > Message: Unhandled Error in Silverlight Application  Code: 4004   
    > Category: ManagedRuntimeError      Message:
    > System.ServiceModel.DomainServices.Client.DomainOperationException:
    > Submit operation failed validation. Please inspect
    > Entity.ValidationErrors for each entity in EntitiesInError for more
    > information.    en
    > System.ServiceModel.DomainServices.Client.OperationBase.Complete(Exception
    > error)    en
    > System.ServiceModel.DomainServices.Client.SubmitOperation.Complete(OperationErrorStatus
    > errorStatus)    en
    > System.ServiceModel.DomainServices.Client.DomainContext.<>c__DisplayClassb.<SubmitChanges>b__3(Object
    > )

    Below is the Save method used:

     

    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();


     

    where _currentcustomer is the A's entity Object, CVEReference is the B's entity object, AddrView is the entityset of the Table View and addresscollection is the collection of C. I don't know where I am going wrong. Kindly guide me through this issue.


    Thank you.