I have a List A as below
var act= (from a in _db.Activities
where a.UserID == userid
select new SchoolDetail
{
SchoolName = a.School,
SchoolCode = a.SchoolID
}).Distinct().ToList();
Then I have another list List B
var sch= (from s in _db.Schools
where s.UserID == userid
select new SchoolDetail
{
SchoolName = s.SName,
SchoolCode = s.SCode
}).Distinct().ToList();
Now I want to append List B to List A and I tried using AddRange -
var schools = act.AddRange(sch);
But I am getting an error message on AddRange line -
Exceptions - Argument null exception
Cannot assign void to an implicitly-typed variable
What am I doing wrong and how can I fix it?
Thanks!
Solved it using a Concat instead of AddRange
var schools = act.Concat(sch);