Hey I'm working on a school project and when I set the variable of a class it throws me a NullReferenceException You can find the full project @ https://github.com/kyllianlissens/BugManagment
if (!dataReader.IsDBNull(dataReader.GetOrdinal("user_id")))
{
task.Employee = (Employee) UserRepository.Items.Find(x => x.Id.Equals(Convert.ToInt32(dataReader["user_id"])));
}
it happens on settings the task.Employee variable
and this is My task class
public class Task : Entity
{
internal Task(int id, Bug bug, string description, int size, TimeSpan timeSpent) : base(id)
{
Bug = bug;
Size = size;
TimeSpent = timeSpent;
Description = description;
Employee = null;
}
public Employee Employee { get; internal set; }
public Bug Bug { get; internal set; }
public string Description { get; internal set; }
public int Size { get; internal set; }
public TimeSpan TimeSpent { get; internal set; }
internal void AddTime(TimeSpan time)
{
TimeSpent += time;
}
}
I also tried removing the Employee = null; but that doesn't change anything.