This question is related to a previous question of mine
That\'s my current code
IEnumerable Get()
{
while(//get implementation
Use the following extension method to break the input into appropriately sized subsets
public static class IEnumerableExtensions
{
public static IEnumerable> InSetsOf(this IEnumerable source, int max)
{
List toReturn = new List();
foreach(var item in source)
{
toReturn.Add(item);
if (toReturn.Count == max)
{
yield return toReturn;
toReturn = new List();
}
}
if (toReturn.Any())
{
yield return toReturn;
}
}
}
then persist the subsets
void Insert()
{
var actual = Get();
using (var db = new DataClassesDataContext())
{
foreach (var set in actual.InSetsOf(5))
{
db.Shapes.InsertAllOnSubmit(set);
db.SubmitChanges();
}
}
}
You might also find this MSDN article on InsertOnSubmit() vs InsertAllOnSubmit() to be useful.