What I'm trying to do:
I'm trying to join two diferent tables so I can show them in my view with my view model..
It works fine when I don't have similar Id's
Problem:
Everytime I add a new scholarship and I try to view the list again I get an error message "Object Null Reference Exception".. but if I restart my proyect in visual studio everything works just fine..
Question:
How can I check if my new object is not null??
Anyone knows why I need to restart my proyect in order to view my data??
(I'm using asynchronous & await to call my db's.. don't know if that has anything to do with anything.)
..Thanks in advance!
=> My last attempt...
var model = students.Join(scholarshipsRequests,
x => x.ScholarshipId ?? 0, y => y.ScholarshipId,
(x, y) => x != null && y != null ? (new AdminScholarshipReqViewModel
{
StudentId = x.StudentId,
ScholarshipId = y.ScholarshipId,
Tag = x.Tag,
FullName = x.FullName,
Division = x.Career.Division,
Company = y.Company,
Comments = y.Comments,
CreationDate = y.CreationDate,
ClassificationDescription = y.Classifications.Description,
}) : new AdminScholarshipReqViewModel()
{
StudentId = 0,
ScholarshipId = 0,
Tag = "",
FullName = "",
Division = "",
Company = "",
Comments = "",
CreationDate = DateTime.Now,
ClassificationDescription = "",
}).ToPagedList(pageNumber, pageSize);
if (model != null) return View(model);