I have two tables as shown below
Table 1 -
LR
ID___________Name
1 A
2 B
3 C
Table 2 -
Mapper
ID___________LRID
1 1
2 1
3 2
The
Mapper table refers
LR table. I am trying to get the data from
LR table wherever the IDs match.
While debugging, in Results View it shows the following message,
"Object reference not set to an instance of an object"
What I have tried:
var rcollection = ObjectFactory.GetInstance<ILRRepository>().GetLR();
var mcollection = ObjectFactory.GetInstance<IMapperRepository>().GetMapper();
var result = rcollection.GroupJoin(mcollection, rcoll => rcoll.ID, mcoll => mcoll.LRID,
(r, m) => new
{
rc = r,
mc = m
})
.SelectMany(xy => xy.mc.DefaultIfEmpty(),
(rco, mco) => new
{
rton = rco.rc,
mton = mco
})
.Select(s => new
{
lrId = s.rton.ID,
lrname = s.rton.Name,
lock = s.mton.LRID == s.rton.ID ? true : false
});
Where have I possibly gone wrong?