Syntax for where column is null

Thread is closed for posting
2 posts, 0 answers
  1. S
    S avatar
    1 posts
    Member since:
    Jul 2011

    Posted 04 May 2012 Link to this post


    I am trying to write a condition where I need to return all rows in a table where a particular column is either blank or null.

    I am using the following code:
         String condition;
                        condition += @" (CustomerId == """ + ItemObject.CustomerId  + @""" or CustomerId   is null)";

    Its not working. Can someone help me with some syntax that I can use?

  2. Ady
    Ady avatar
    589 posts

    Posted 09 May 2012 Link to this post

    Hi Maggi,

     Are you using LINQ or OQL or plain SQL? What is the data type of the column? If you are using LINQ and it is a character column you could write something like
    var q = context.YourType.Select( t => string.IsNullOrEmpty(t.FieldName))

    Do let me know if this helps or else some more information on the exact use case would help in providing a more specific answer.

    All the best,
    the Telerik team
    Follow @OpenAccessORM Twitter channel to get first the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
Back to Top