Submitchanges() does not update data in Linq

Asked

Viewed 41 times

0

internal bool AlterarCargo(string login, string Categoria)
{
    db.Log = Console.Out; //tentei ativar para ver se encontrava o erro mas não ajudou nada.
    var categoria = from x in db.Categorias
                    where x.Categorias == Categoria
                    select x.Id_Categorias;

    var Id_Inscricao = from x in db.DadosPessoaisComuns
            where x.login == login
            select x.Id_Inscricao;

    var query = from x in db.DadosCategorias
                where x.Id_Inscricao == Convert.ToInt16(Id_Inscricao.First())
                select x;

    foreach (var item in query)
    {
        item.Id_Categorias = categoria.First();
        MessageBox.Show(item.Id_Categorias.ToString() + "  " + item.Id_Inscricao.ToString());  // mostra os dados já atualizados
    }

    db.SubmitChanges();

    return true;
}

When I consult the database data has not been updated

1 answer

0


The problem was in the database. Although no error occurs in visual studio the problem is that it did not have the updated model with that of the database.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.