I’m trying to compare a string field from a LINQ query on a database using:
e.Comment.equals("Working From Home")
on the WHERE clause.
However, sometimes the Comment field could be empty which currently causes an Object reference not set to an instance of an object exception.
Is there any way I can check if the Comment isn’t empty and THEN compare to avoid the exception?
You can use
==instead of Equals:LINQ to SQL will correctly translate this to the appropriate SQL syntax.