title: Ormlite Where-Contains Fails
body: <p>I'm attempting to query my db using <code>Enumerable.Contains</code> inside a <code>SqlExpressionVisitor.Where</code>clause. When the lambda is compiled, I'm getting a null reference exception.</p>
  
  <p>When the visitor makes it to <code>foreach (Object e in inArgs)</code> (currently line 1067) inside <code>SqlExpressionVisitor.VisitArrayMethodCall</code>, it chokes because <code>inArgs</code> is null. The following is my sample that causes the error. I don't understand lambdas/expressions well enough to know why this is happening. </p>
  
  <p><strong>So my questions is</strong>, am I not using the <code>Where</code> clause properly or is this a bug?</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          var connectionFactory = new OrmLiteConnectionFactory(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|Database1.mdf;Integrated Security=True;User Instance=True", SqlServerDialect.Provider);
          SetupDb(connectionFactory);           
  
          using (var db = connectionFactory.OpenDbConnection())
          {
              var numbersToSelect = new int[2] { 1, 2 };
              db.Select&lt;SomeObject&gt;(e =&gt; e.Where(o =&gt; numbersToSelect.Contains(o.Number)));
          }
      }
  
      static void SetupDb(IDbConnectionFactory connectionFactory)
      {
          using (var db = connectionFactory.OpenDbConnection())
          {
              db.DropTable&lt;SomeObject&gt;();
              db.CreateTable&lt;SomeObject&gt;();
              db.Insert(new SomeObject { Number = 1 });
              db.Insert(new SomeObject { Number = 2 });
              db.Insert(new SomeObject { Number = 3 });
              db.Insert(new SomeObject { Number = 4 });
              db.Insert(new SomeObject { Number = 5 });
          }
      }
  }
  
  class SomeObject
  {
      public int Number { get; set; }
  }
  </code></pre>
  
  <hr>
  
  <p>After a little more digging, it turns out calling the compiled method is returning an <code>int[]</code> which causes the cast to <code>object[]</code> to be null. Casting to <code>IEnumerable</code> fixes my specific issue.</p>
  
  <p>Changed</p>
  
  <pre><code>var getter = lambda.Compile();
  var inArgs = getter() as object[];
  </code></pre>
  
  <p>to</p>
  
  <pre><code>var getter = lambda.Compile();
  var inArgs = getter() as IEnumerable;
  </code></pre>
  
  <p>Not sure what sort of implications this has though (if any). Still looking for some guidance.</p>