I'm trying to add a value to a List<>. The List<> is a column in my Users model. When I execute the Add() function I get the error message 'NullReferenceException was unhandled by user code'. I'm certain that the row that I'm attempting to modify exists. Here's a sample of my code:
var user2 = from check in myfirstDB.Users where check.Name.Equals("stu") select check;
user2.Single().discussionsIdList.Add(1);
Here's my Users model:
public class User
{
public int Id { get; set; }
public string Name { get; set; }
public string email { get; set; }
public string password { get; set; }
public int rank { get; set; }
public List<int> discussionsIdList { get; set; }
}
Thanks in advance.