im having a System.NullReferenceException and dont know why, and dont find the solution, i searchig for a solution around 3 hours, and nothing, someone can helpme , please, ill apreciated it here is my class, and my method with the trouble
public class FuenteDatos
{
private Contexto db = new Contexto();
public List<string> Area { get; set; }
public List<int> Cantidad { get; set; }
public FuenteDatos ObjetenerDatosDescripcion(string parametro)
{
FuenteDatos obj = new FuenteDatos();
var porAreas = from receptores in db.AFTs
where receptores.Descripcion == parametro
group receptores by receptores.Receptor.AreaTrabajo into tablanueva
select new {
a = tablanueva.Key,
c = tablanueva.Count(),
};
//debugin i have all the rights values, till this point everything is ok
foreach(var objeto in porAreas)
{
//here is the exeption system null reference , WHYY? the anonymous field "a" is not empty
//or null
obj.Area.Add(objeto.a);
obj.Cantidad.Add(objeto.c);
}
return obj;
}
}