I have this piece of code :
Verification verif = dal.getAllVerifs().Where(v => v.interfa == inter).ToList().FirstOrDefault(v => v.nom == tache.nom);
string name = verif.str.nomStruct;
return RedirectToAction("Index", "Home", new {error = name });
An exception is thrown :
Object reference not set to an instance of an object.
I looked it up, my Verification object has every attribute filled, except for the "str" attribute ( a "Structure" object), which is null .
This is just supposed to return all the rows of one of my tables :
public List<Verification> getAllVerifs()
{
return bdd.verifications.ToList();
}
my model :
[Table("Structure")]
public class Structure
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int strucutureId { get; set; }
[Required]
public string nomStruct { get; set; }
[Required]
public bool isXsdExistant { get; set; }
}
[Table("Taches_Verification")]
public class Verification
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int VerifId { get; set; }
[Required]
public string nom { get; set; }
[Required]
public string feuille { get; set; }
[Required]
public Interface interfa { get; set; }
[Required]
public Structure str { get; set; }
[Required]
public int numOrdre { get; set; }
}
I looked in the database, the primary key of the table that contains the "structure" objects is filled and is ok.
Have you ever experienced this problem ?
Thanks
K.