-1
Friends, I had a table Pessoa
that contained a lot of user information. I decided to create a table Aluno
to separate the information. My tables are like this:
Person:
Cod
,Nome
,Senha
Pupil:Cod
,Status
,Data_Registro
,PessoaId
I am trying to get a list of requests from the connected user. However, my table Pedidos
has a key to the table Alunos
, not for the table Pessoa
. The information of Aluno
is null. How can I include it in the table Pessoa
?
Error:
System.NullReferenceException:
'Object reference not set to an instance of an object.'
LojaVirtual.Models.pessoa.aluno.get retornou null.
Pedidocontroller.Cs
public IActionResult Index(int pagina)
{
pessoa pessoa = _loginPerson.GetPessoa();
var requests= _requestRepository.ObterTodosPedidoPessoa(pagina, pessoa.aluno.Cod);
return View(pedidos);
}
Médoto Getpessoa()
public pessoaGetPessoa()
{
//Deserializar
if( _sessao.Existe(Key)) {
string pessoaJSONString = _sessao.Consultar(Key) ;
return JsonConvert.DeserializeObject<pessoa>(pessoaJSONString);
}
else
{
return null;
}
}
Method Consult
public string Consultar(string Key)
{
return _context.HttpContext.Session.GetString(Key);
}
I thank you for any comment!
This answers your question? What causes the 'System.Nullreferenceexception'?
– Bruno Warmling
Welcome to the Stack Overflow in Portuguese. As the name suggests, the official language used here is Portuguese. So, could you please translate your question? If you prefer, you can also ask the same question on Stack Overflow English Website.
– Bruno Warmling
Thanks for the tip. I did the @Brunowarmling translation. I saw the link that went through, but it wasn’t quite that!
– Edrian Biagi