EDIT: you need to check c for null, namely c after your grouping. See my updates below.
You need to do tClassCode c null check in your select statement. What type of tClassCode ? You should be able to perform a null check on the value of c , and if it is null, assign a NULL value of the appropriate type and return it, otherwise return the actual value.
Since Iβm not sure if tClassCode is tClassCode be an integer, in this case the cast will have an integer with a null value ( Integer? ). With that in mind, your select statement, which will be added at the end of what you still have, should resemble:
Since tClassCode is a line that will look like your code:
Select _ e, _ Code = If(c Is Nothing, Nothing, c.tClassCode)
Depending on what you need to do, if c is null, you can return String.Empty instead of Nothing :
Select _ e, _ Code = If(c Is Nothing, String.Empty, c.tClassCode)
Of course, you can further expand the "e" selection to design its specific columns by name.
It is important to understand that you must check c for null before using any of its properties, since it can be zero depending on the result of an external outer join for a particular result (string). Returning to my earlier example, if you have another field named Priority that was an integer that you would choose against nullable:
Select _ e, _ Priority = If(c Is Nothing, CType(Nothing, Integer?), c.Priority)