0

我收到此错误:

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 选项) 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:林哈 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;
        }
    }

ADDUSocate(我遇到错误的地方)

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

4

1 回答 1

1

会不会是Azure 字符大小写问题?也许您没有为"UserEntities".

[更新]

这可能是因为您获得了对"fiscal"表的引用,但您想将实体添加到"UserEntities"表中。

有一个很好的示例说明如何在此处添加实体:CloudTableClient.CreateTableIfNotExist 方法

于 2013-01-18T12:57:50.407 回答