Ola, Estou tendo dificuldades para preencher um objeto, eu criei um método para preenche-lo: public static Os PreenherObjeto(SqlDataReader reader)
{
Os os = new Os();
os.id = reader.GetInt32(0);
os.status.Nome = reader.GetString(1);
os.usuario.Nome = reader.GetString(2);
os.responsavel.nome = reader.GetString(3);
os.dataInicial = reader.GetDateTime(4);
os.descricao = reader.GetString(5);
os.setor.Nome = reader.GetString(6);
os.motivo.nome = reader.GetString(7);
os.solucao = reader.GetString(8);
os.nomeUsuario = reader.GetString(9);
os.patrimonio = reader.GetString(10);
os.ramal = reader.GetString(11);
os.Email = reader.GetString(12);
return os;
}
quando eu começo a preenche-lo da o seguinte erro:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 52:
Line 53: os.id = reader.GetInt32(0);
[b]Line 54: os.status.Nome = reader.GetString(1);[/b]
Line 55: os.usuario.Nome = reader.GetString(2);
Line 56: os.responsavel.nome = reader.GetString(3);