title: how to combine two fields in linq?
body: <p>I have the following an entity I want to search on.. how can I combine two fields to get the correct input..</p>
  
  <p>something like this</p>
  
  <pre><code>var personnels = dbContext.Set&lt;Personnel&gt;()
                            .Where(p =&gt; 
                               (p.FirstName + ' ' + p.Surname).Contains("John Smith")
                            );
  </code></pre>
  
  <p>When I do that it says</p>
  
  <blockquote>
    <p>Unable to create a constant value of type 'System.Object'. Only primitive types or enumeration types are supported in this context.</p>
  </blockquote>
  
  <p>This is the code I am trying to fix</p>
  
  <pre><code>var personnels = dbContext.Set&lt;Domain.Entities.App.Personnel&gt;().Where(p =&gt;
              ((p.GivenName  + p.Surname).Contains(criteria.PersonnelName) ||  String.IsNullOrEmpty(criteria.PersonnelName))
               &amp;&amp; (p.PersonnelRoleId == criteria.PersonnelRoleId || (criteria.PersonnelRoleId ?? 0) == 0)
               &amp;&amp; (((criteria.ActiveOnly &amp;&amp; (p.ActiveFlag)) || (criteria.ActiveOnly == false)))).AsEnumerable();
  </code></pre>
  
  <p>The code works, but it only works if the criteria is johnsmith not john smith..</p>
  
  <p>so the line is this</p>
  
  <pre><code>(p.GivenName  + p.Surname).Contains(criteria.PersonnelName) 
  </code></pre>
  
  <p>how can I get a space in there</p>
  
  <pre><code>(p.GivenName  + ' ' +  p.Surname).Contains(criteria.PersonnelName)  
  </code></pre>
  
  <p>doesn't work</p>