none
Cannot add an entity that already exists RRS feed

  • Question

  • I get the error "Cannot add an entity that already exists" on submit changes but i set a new ID which is unique using getnextnumberbyseries function IndentId field is not set Identity in table but its unique so i have to manage it manually.

    why i m getting is error i can't understand.

    what i am trying to accompalish here is take a row from table Indent then add new Indent ID and Series and save that record as new record.

    TblIndent objActualNew = new TblIndent();
                Int32 intActualId = 0;
    
                var varTempInden = (from a in DB.TblIndent where a.IndentId == Convert.ToInt32(tempIndentID) select a).Single();
    
                objActualNew = varTempInden;
                intActualId = ds.getNextNumberBySeries("tblIndent", "Actual", "IndentId");
                objActualNew.IndentId = intActualId;
                objActualNew.Series = "Actual";
                objActualNew.CreatedBy = Program.currentuser.UserCode;
                objActualNew.CreateDt = DateTime.Now;
                DB.TblIndent.InsertOnSubmit(objActualNew);
                DB.SubmitChanges();
    

    Wednesday, July 4, 2012 6:18 AM

Answers

  • Thanks I resolve the issue by assigning individual fields to new object a hectic task but it gets the job done.

    CODE to make the world better

    Thursday, July 5, 2012 2:31 AM

All replies