title: Why can't I Concat or Union results to an empty List?
body: <p>Unfortunately, SQL Server can not a handle a parameter list which exceeds 2100 parameters. I have a couple of queries which when run in a batch mode exceed this limit. To still get the results I want and quickly cycle through the data set I have decided to make use of <code>Skip(i).Take(2000)</code> in a for loop.</p>
  
  <p>What I was not prepared for was that both <code>Union</code> and <code>Concat</code> require an <code>IEnumerable</code> to be more than just instantiated to work. Sure it's an empty, but I must be missing something fundamental about their use. At any rate, to solve the issue I ended up using a List and <code>AddRange</code>. I am making use of NHibernate, but don't think that factors into why <code>Union</code> and <code>Concat</code> aren't working.</p>
  
  <pre><code>var machineResults = new List&lt;Machine&gt;();
  
  for (int i = 0; i &lt; machines.Count(); i += 2000)
  {
                     // I would have expected Union or Concat to work here
      machineResults.AddRange(GetSession().CreateQuery(
         @"select distinct m
          from Machine m
          where m in (:MachinesList)") // there's more criteria than this
         .SetParameterList("MachinesList",
                            machines.Skip(i).Take(2000).ToList())
         .List&lt;Machine&gt;());                
  }
  
  return machineResults;
  </code></pre>
  
  <p>So what am I missing about <code>Union</code> and <code>Concat</code>? Why don't they work in the above statement? I understand why AddRange works, but what if I was concerned about the uniqueness of my results and wanted to use <code>Union</code>?</p>