I am having troubles inserting entities in linq after deleting them (without submitting the changes).
List<AlergiesPerPersonBE> AlergiesPerPerson = AlergiesPerPersonToInsert;
RepositoryFactory.GetAlergiesPerPersonRepository().DeleteWhere(x => x.PersonId == id);
RepositoryFactory.GetAlergiesPerPersonRepository().Insert(AlergiesPerPerson);
DataContextFactory.SubmitChanges();
Both (delete and insert) don´t submit any changes. They just InsertAllOnSubmit and DeleteAllOnSumbit.
The code works fine the first time. All the details are inserted properly. The second time that I run the same code, all rows of the db are deleted. The third time, all works fine. It works, then it doesn’t, and so on.
Try
There’s no reason that you have to submit changes only once per unit of work. Note that this will still work with any transactions that you have.