When filling a list in a ViewModel, I get the error:
Reference to object not established as an instance of an object.
The ViewModel is this:
public class vmMovimientosParking
{
public vmMovimientosParking()
{
List <tipoPersonal> tipoPersonal = new List<tipoPersonal>();
}
public List<Empresa> ListaDepartamento { get; set; }
public List<MovimientosParking> marcaje { get; set;}
public List <tipoPersonal> tipoPersonal { get; set; }
}
Where I call it:
foreach (var m in coches)
{
resultadoProvisional.AddRange(marcaje.Where(ma => ma.Matricula == m.MAT).ToList());
tipoPersonal nuevo = new tipoPersonal();
nuevo.numEmp = m.NUM;
nuevo.tipoEmp = m.TIPO;
nuevo.nombre = m.NOMBRE;
nuevo.apellidos = m.APELLIDOS;
modelo.tipoPersonal.Add(nuevo); //Aqui salta el error
}
And the personal type object:
public class tipoPersonal
{
public int numEmp;
public string tipoEmp;
public string nombre;
public string apellidos;
}