title: Linq Query ignore empty parameters
body: <p>How do I get Linq to ignore any parameters that are empty?  So Lastname, Firstname, etc?  If I have data in all parameters it works fine...</p>
  
  <pre><code>refinedresult = From x In theresult _
                      Where x.&lt;thelastname&gt;.Value.TestPhoneElement(LastName) And _
                      x.&lt;thefirstname&gt;.Value.TestPhoneElement(FirstName) And _
                      x.&lt;id&gt;.Value.TestPhoneElement(Id) And _
                      x.&lt;number&gt;.Value.TestPhoneElement(Telephone) And _
                      x.&lt;location&gt;.Value.TestPhoneElement(Location) And _
                      x.&lt;building&gt;.Value.TestPhoneElement(building) And _
                      x.&lt;department&gt;.Value.TestPhoneElement(Department) _
                      Select x
  
  
  Public Function TestPhoneElement(ByVal parent As String, ByVal value2compare As String) As Boolean
  'find out if a value is null, if not then compare the passed value to see if it starts with
  Dim ret As Boolean = False
  
  If String.IsNullOrEmpty(parent) Then
      Return False
  End If
  If String.IsNullOrEmpty(value2compare) Then
      Return ret
  Else
      ret = parent.ToLower.StartsWith(value2compare.ToLower.Trim)
  End If
  
  Return ret
  End Function
  </code></pre>