2013-01-18 18 views
0

我得到這個錯誤:Windows Azure的錯誤C#

f:Erro ao processar esta solicitação.| em System.Data.Services.Client.DataServiceContext.SaveResult.HandleBatchResponse() em System.Data.Services.Client.DataServiceContext.SaveResult.EndRequest() em System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions options) em AzureTableLayer.CRUDUserEntities.ADDUSociate(UserClientEntity entity) na \WindowsAzureProject1\AzureTableLayer\User\CRUDUserEntities.cs:linha 43 em mobile.Service1.addusr(String nome, String cidade, String cpf, String email, String telefone) na \Service1.svc.cs:linha 124

的方法是:

public string addusr(string nome, string cidade, string cpf, string email, string telefone) 
    { 
     try 
     { 
      if (nome.Length == 0) 
       return "f:Preencha o campo nome."; 

      if (cidade.Length == 0) 
       return "f:Preencha o campo cidade."; 

      if (cpf.Length == 0) 
       return "f:Preencha o campo cpf."; 

      if (!Valida(cpf)) 
       return "f:CPF Invalido."; 

      if (email.Length == 0) 
       return "f:Preencha o campo email."; 

      Regex rg = new Regex(@"^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$"); 
      if (!rg.IsMatch(email)) 
      { 
       return "f:Email Invalido"; 
      } 

      List<UserEntity> lst = new List<UserEntity>(); 
      var _account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn")); 
      _account.CreateCloudTableClient().CreateTableIfNotExist("fiscal"); 
      var _context = new CRUDUserEntities(_account.TableEndpoint.ToString(), _account.Credentials); 


      UserClientEntity entity = new UserClientEntity() { nome = nome, cidade = cidade, cpf = cpf, email = email, telefone = telefone }; 
      _context.ADDUSociate(entity); 

      return "k"; 
     } 
     catch (Exception exc) 
     { 
      string error = "f:" + exc.Message + "|" + exc.StackTrace; 
      // Trace.WriteLine("Erro no login: " + error , "Information"); 
      return error; 
     } 
    } 

的ADDUSociate(其中我收到提示)

public void ADDUSociate(UserClientEntity entity) 
    { 
     this.AddObject("UserEntities", new UserEntity { nome = entity.nome, cpf = entity.cpf, cidade = entity.cidade, email = entity.email, telefone = entity.telefone}); 
     this.SaveChanges(); 
    } 

編輯:問題出在this.SaveChanges();

回答

1

難道是Azure character casing issue?也許你沒有使用正確的外殼"UserEntities"

[更新]

這可能是因爲你到了"fiscal"表的引用,但你要對實體添加到"UserEntities"表。

還有就是如何可以在這裏添加一個實體的好例子:由於參數是UserClientEntity和方法** ** ADDUSociate是** ** UserEntity和參數是** UserClientEntity CloudTableClient.CreateTableIfNotExist Method

+0

** – Ladessa

+0

好的,我已經更新了我的答案。 –