title: C# LINQ dynamic Query translate to stored procedure
body: <p>I'm new to SQL and trying to translate a C# linq query to a stored procedure.</p>
  
  <p>The Linq query looks like this:</p>
  
  <pre><code>if (subscription.address1 != null) 
     address1 = subscription.CountryNames.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
  
  if (subscription.address2 != null) 
     address2= subscription.CountryNames.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
  
  var query = context
                 .Information
                 .Where(item =&gt; item.AppearanceDate &gt;= dateFromDT &amp;&amp; item.AppearanceDate &lt;= dateToDT);
  
  if (address1.Count &gt; 0)
      query = query.Where(item =&gt; address1.Contains(item.address1));
  
  if (address2.Count &gt; 0)
      query = query.Where(item =&gt;  address2.Contains(item.address2));
  
  var results = query.select.toList()
  </code></pre>
  
  <p>Table name: <strong>Information</strong></p>
  
  <p>Columns: </p>
  
  <pre><code>Person_Name
  address1
  address2
  </code></pre>
  
  <p><code>address2</code> and <code>address1</code> are passed in</p>
  
  <p>How do I write a stored procedure for this?</p>
  
  <p>Must I create a <code>#Temp</code> table for each address and query from? Thanks in advance</p>