How to get a block of data from an IEnumarable
<p>I need to get a block of data from an IEnumerable. I found a solution but I want to now if there is a more efficient solution. This is my code:
... </p>

<pre><code>foreach (var item in pocoListToInsert)
{
   var pd = PetaPoco.Database.PocoData.ForType(pocoListToInsert.First().GetType());
   maxRecords = maxParam / pd.Columns.Count;
   if (list.Count &lt; maxRecords)
      list.Add(item);
   else if (list.Count == maxRecords || item == lastRecord)
   {
      Insert(pd.TableInfo.TableName, pd.TableInfo.PrimaryKey, true, pocoListToInsert);
      list.Clear();
   }
} 
</code></pre>
