1
When I give a savechanges(), records to all tables and would like just one. How do I do? Tables Acao and ProximaAcao also inserts record.
public T_TarefaParceiro geraIdParceiro()
{
    WEBEntities db = new WEBEntities();
    T_ParceiroOs osParceiro = new T_ParceiroOs();
    T_TarefaParceiro tarefa = new T_TarefaParceiro();
    T_ParceiroTarefa _tarefa = new T_ParceiroTarefa();
    T_Acao t = new T_Acao();
    T_ProximaAcao tp = new T_ProximaAcao();
    int _idAcao = 0;
    int _idProxima = 0;
    try
    {
        var tipoEstabelecimento = new List<int>{2,3,4,5,6};
        if (geraIdNovoPdv() == true)
        {
            var novo = db.T_PDV.Join(
                db.T_CRM_StatusPDV, t1 => t1.CNPJ, t2 => t2.DE_Cnpj,
                (t1, t2) => new { t1, t2 })
                .Where(c => c.t2.DT_TransacaoV == null && tipoEstabelecimento.Contains(c.t1.IDTipoEstabelecimento))
                .Select(i => new { i.t1.CNPJ });
            var acao = db.T_Acao.Join(db.T_ProximaAcao,
                t1 => t1.IDAcao, t2 => t2.IDAcao,
                (t1, t2) => new { t1, t2 })
            .Where(a => a.t1.IDAcao == a.t2.IDAcao && a.t1.IDAcao == 7)
            .Select(i => new { i.t1.Acao, i.t2.ProximaAcao, i.t1.IDAcao, i.t2.IDProximaAcao});
            foreach (var lista in novo)
            {
                osParceiro.PdvNovo = 1;
                osParceiro.Cnpj = lista.CNPJ;
            }
            foreach (var lista in acao)
            {
                osParceiro.AcaoParceiro = lista.Acao;
                osParceiro.ProximaAcao = lista.ProximaAcao;
                _idAcao = lista.IDAcao;
                _idProxima = lista.IDProximaAcao;
                t.Acao = lista.Acao;
                tp.ProximaAcao = lista.ProximaAcao;
            }
            tarefa.CNPJ = osParceiro.Cnpj;
            tarefa.IDAcao = _idAcao;
            tarefa.IDProximaAcao = _idProxima;
            tarefa.T_Acao  = t;
            tarefa.T_ProximaAcao = tp;
            db.T_TarefaParceiro.Add(tarefa);
            db.SaveChanges();
        }
        else if (geraIdPdvV99() == true)
        { 
        }
    }
    catch (Exception ex)
    {
        string erro = ex.Message;
    }
    return tarefa;
}
I did it here, following the guidance of the Gypsy and now the browser does not show. I think it has to do with the return XML.
t.IDAcao = lista.IDAcao;
t.Acao = lista.Acao;
tp.IDProximaAcao = lista.IDProximaAcao;
tp.ProximaAcao = lista.ProximaAcao;
And I called it that:
tarefa.T_Acao = t;
tarefa.T_Acao = t;
What really might be happening?
It is a web service REST. The interface of this method is this:
[OperationContract]
        [WebInvoke(
            Method = "GET", // Tipo de request
            BodyStyle = WebMessageBodyStyle.Bare, // Identação do retorno
            UriTemplate = "abreos" // Url do serviço, onde cada {} = parametro
            )]//Filter para tratar REST
        T_TarefaParceiro geraIdParceiro();
How do I build XML I don’t know, just a WS REST that assembles this XML according to the method’s response, right? I do not have this domain of the subject, rs.
I laughed with that title. I already answer you.
– Leonel Sanches da Silva
Sometimes even the title gets hard to choose
– pnet