Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a sharepoint list: MyList

I insert item to this list by Linq to Sharepoint (context object) like this:

context.MyList.InsertAllOnSubmit(data.Items.Select(n => dataConvertor.Convert(n)));
context.SubmitChanges();

Convert method:

MyListItem = new MyListItem()
{
   Column1 = "1";
   Column2 = "2";
   Column3 = "3";
}

The data is received from an excel file but for some excel files I get the Error: Cannot insert an entity that already exists.

I tried to do:

var myist = data.Items.Select(n => dataConvertor.Convert(n));
foreach (var item in myList)
{
   context.MyList.InsertOnSubmit(item);
   context.SubmitChanges();
}

It worked but because the data is very large it took a lot of time...

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.