Borrowed bits from various threads and tried this code..
Transaction trx = new Transaction(IsolationLevel.ReadUncommitted, "MakeSomeItems");
// We need to be allowed to insert into IDENTITY field in Item
IDbCommand cmd = trx.ConnectionToUse.CreateCommand();
cmd.Transaction = trx.PhysicalTransaction;
cmd.CommandText = "set IDENTITY_INSERT Class on";
cmd.ExecuteNonQuery();
ClassEntity ce = new ClassEntity();
ce.Fields["ClassId"].ForcedCurrentValueWrite(234);
ce.AcadDataset = "2007";
ce.SubjectId = 5;
trx.Add(ce);
ce.Save();
cmd = trx.ConnectionToUse.CreateCommand();
cmd.Transaction = trx.PhysicalTransaction;
cmd.CommandText = "set IDENTITY_INSERT Class off";
cmd.ExecuteNonQuery();
//We're done
trx.Commit();
I get an error because the PK (ClassId has no value) and I thought ForcedCurrentValueWrite would do it? Any thoughts?
Mark