0

when I debug the code below error nullable object must have a value returned on line objLstRole = objLstRole.Where(Function(x) x.HQA = UserInfo.HQA).ToList()

Dim objLstRole As New List(Of Common.Role)()
                    objLstRole = r.selectAll().ToList()
                    Dim UI As Common.Objects.User = Session("userinfo")
                    If Not UI.TrainingCenter Then
                        objLstRole = r.selectAll().ToList()
                        TxtPassword.TextMode = TextBoxMode.SingleLine
                    Else
                        objLstRole = objLstRole.Where(Function(x) x.TrainingCenter = True).ToList()
                        TxtPassword.TextMode = TextBoxMode.Password
                    End If

                    If UserInfo.User_Id <> "Admin" Then
                        If UserInfo.HQA Then
                            objLstRole = objLstRole.Where(Function(x) x.HQA = UserInfo.HQA).ToList()
                        ElseIf UserInfo.Field Then
                            objLstRole = objLstRole.Where(Function(x) x.Field = UserInfo.Field).ToList()
                        End If
                    End If

Please any advise how can I solve this problem...

1

1 Answer 1

0

finally I found reason.. this happens cause HQA column in roles table null so I should check it before say where in list collection:

objLstRole = objLstRole.Where(Function(x) x.HQA IsNot Nothing And x.HQA = UserInfo.HQA).ToList()  
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.