문제

I have a code like this.

DBContext is Datacontext instance.

try
            {
                TBLORGANISM org = new TBLORGANISM();
                org.OrganismDesc = p.Subject;
                DBContext.TBLORGANISMs.InsertOnSubmit(org);
                DBContext.SubmitChanges();
            }
            catch (Exception)
            {
            }

At this point, I want to IGNORE the error and want to be skipped. Not to be retried. But when I try another insert like

                TBLACTION act = new TBLACTION();
                act.ActionDesc = p.ActionName;
                DBContext.TBLACTIONs.InsertOnSubmit(act);
                DBContext.SubmitChanges();

SubmitChanges firstly retries previous attempt.

How can I tell "skip errors, don't try again"?

도움이 되었습니까?

해결책

Create a new instance of DBContext the second time.

But why do you want to skip errors?

다른 팁

Try this: DBContext.SubmitChanges(ConflictMode.ContinueOnConflict). Hope it will help.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top