title: How to check if property exists in Type in an extension method?
body: <p>I frequently have code like this:</p>
  
  <pre><code>var stRecs = db.&lt;someTable&gt;
               .Where(a =&gt; a.DepID == depID)
  </code></pre>
  
  <p>to select a single record, however if <code>depID == 0</code> I would like to get back all records.</p>
  
  <p>I was thinking about creating an extension method "WhereDepID_OrAll", like</p>
  
  <pre><code>public static IQueryable&lt;T&gt; WhereDepID_OrAll&lt;T&gt;(this IQueryable&lt;T&gt; source)
          where T: // is what?
  {
      if(depID &gt; 0) { return source.Where(a =&gt; a.depID == depID); }
      else return source.Where(a =&gt; a);
  }
  </code></pre>
  
  <p>Now my basic question is:
  I have several tables with depID - how do I set the <code>Where T:</code> ?<br>
  How would the method determine, whether the table has depID?</p>
  
  <p>A better approach to the underlying problem?</p>