I have a project and use Entity Framework to work with database. I get this error when I want to get list of entity.
Object reference not set to an instance of an object
Code:
var query = db.FSefareshArt
.Where(se => se.SefareshID == intSefareshId)
.ToList()
.Select(se => new { se.ArtID, se.KalaID, se.Kala.KalaName, se.Kala.Abead, se.Count, se.Kala.Vahed, se.SefareshID, se.Person.FullName, se.ArtStateID, StateTitle = Upset.GetSefArtState(se.ArtID), se.Description, se.CreationDateTime })
.ToList();
When I run the project, it works without error, but when I insert a new record, this error happens.
Entity Kala in se.Kala is null. Why?