Click here to Skip to main content
15,063,556 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
It giving me Error as Object is not set to instance of object

C#
var query = (from attendace in ListAttendace_Details
                       join makeup in  ListMakeup
                       on attendace.Attendace_ID equals makeup.Attendace_ID
                       into yG
                       from y1 in yG.DefaultIfEmpty()

                       select new { Makup=y1.Attendace_ID==null?0:1,attendace.Status, attendace.ISAttend, attendace.Attendace_ID }).ToList();
Posted
Updated 10-Nov-13 20:47pm
v2

1 solution

I believe you are having your exception on the select line. It is possible that, there is no mapping record present in these other mapping table. Which will return null and null cannot be assigned as select result and this will result in throwing the exception you are having. So try doing the null check to the other select fields you did on the Makup.

Good luck,
OI
   
Comments
Member-515487 11-Nov-13 3:55am
   
Attendance Table

Attendace_ID
1
2

Makeup

MakeID Attendace_ID
1
2

May Makeup does not contain ID
Orcun Iyigun 11-Nov-13 5:51am
   
No but I said try doing what did on Makeup to the other fields meaning status, isAttend, attendance.Attandance_ID...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900