Why do have this error on FundList.children.Add(Fund) ?
An exception of type 'System.NullReferenceException' occurred in ICRC.HRSSD.BAL.dll but was not handled in user code
My model "TaskTree" is a class who there are id, name and children, children is a list of other TaskTree... i need to do that because i have to do a tree ...
public List<TaskTree> getTaskTree(int IdTeam)
{
using (HRSSD_DATA context = new HRSSD_DATA())
{
List<TaskTree> ListAll = new List<TaskTree>();
var person = context.AR_PERSON.Where(a => a.STATUS == "A" && a.CR_GROUP.REF==IdTeam).ToList();
foreach (var item in person)
{
TaskTree FundList = new TaskTree();
FundList.id = item.REF;
FundList.name = item.FULL_NAME;
var task = context.TASK.Where(a => a.IdCurrentOfficer == item.REF && a.BASE_ENTITY_TYPE == 100 && a.OPEN_IND == 1 && a.ACTIVE_TASK == 1 && a.TEMPLATE_IND == 0&& a.TASK_STATUS_REF != 114).ToList();
foreach (var tasks in task)
{
TaskTree Fund = new TaskTree();
Fund.name = tasks.TASK_TITLE;
Fund.id = tasks.TASK_NO;
FundList.children.Add(Fund);
}
ListAll.Add(FundList);
}
return ListAll;
}
}
AND MY TaskTree class
public class TaskTree { public int id; public string name; public List<TaskTree> children; }