public void ConcurrencyOnUpdateDeleteAutoKey() { long oldKey = -1; ConcurrencyTestChildCollection collection = new ConcurrencyTestChildCollection(); switch (collection.es.Connection.ProviderSignature.DataProviderName) { case "EntitySpaces.SqlServerCeProvider": case "EntitySpaces.SqlServerCe4Provider": Assert.Ignore("Not implemented for SqlCe"); break; default: try { using (esTransactionScope scope = new esTransactionScope()) { // Setup ConcurrencyTestChild entity = new ConcurrencyTestChild(); entity.Name = "Test 1"; entity.DefaultTest = Convert.ToDateTime("2010-01-01"); entity.Save(); oldKey = entity.Id.Value; // Test entity = new ConcurrencyTestChild(); entity.LoadByPrimaryKey(oldKey); entity.Name = "Test 2"; ConcurrencyTestChild entity2 = new ConcurrencyTestChild(); entity2.LoadByPrimaryKey(oldKey); entity2.MarkAsDeleted(); entity.Save(); entity2.Save(); Assert.Fail("Concurrency Exception not thrown."); } } catch (EntitySpaces.Interfaces.esConcurrencyException cex) { switch (collection.es.Connection.ProviderSignature.DataProviderName) { case "EntitySpaces.MSAccessProvider": case "EntitySpaces.MySqlClientProvider": case "EntitySpaces.SQLiteProvider": case "EntitySpaces.SqlServerCeProvider": case "EntitySpaces.SybaseSqlAnywhereProvider": case "EntitySpaces.VistaDBProvider": case "EntitySpaces.VistaDB4Provider": Assert.AreEqual("Error in", cex.Message.Substring(0, 8)); break; case "EntitySpaces.OracleClientProvider": Assert.AreEqual("ORA-20101", cex.Message.Substring(0, 9)); break; default: Assert.AreEqual("Update failed", cex.Message.Substring(0, 13)); break; } } finally { // Cleanup ConcurrencyTestChild entity = new ConcurrencyTestChild(); if (entity.LoadByPrimaryKey(oldKey)) { entity.MarkAsDeleted(); entity.Save(); } } break; } }