diff --git a/generator/.DevConfigs/fde42955-138d-44dc-8373-e98e836b33e3.json b/generator/.DevConfigs/fde42955-138d-44dc-8373-e98e836b33e3.json
new file mode 100644
index 000000000000..247831563072
--- /dev/null
+++ b/generator/.DevConfigs/fde42955-138d-44dc-8373-e98e836b33e3.json
@@ -0,0 +1,11 @@
+{
+ "services": [
+ {
+ "serviceName": "DynamoDBv2",
+ "type": "patch",
+ "changeLogMessages": [
+ "Add missing `SkipVersionCheck` property to the `TransactWriteConfig` class (https://github.com/aws/aws-sdk-net/issues/4243)"
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/sdk/src/Services/DynamoDBv2/Custom/DataModel/TransactWrite.cs b/sdk/src/Services/DynamoDBv2/Custom/DataModel/TransactWrite.cs
index 391c6e5d5df3..d0e75f2668df 100644
--- a/sdk/src/Services/DynamoDBv2/Custom/DataModel/TransactWrite.cs
+++ b/sdk/src/Services/DynamoDBv2/Custom/DataModel/TransactWrite.cs
@@ -409,7 +409,7 @@ private void CheckUseVersioning()
if (_config.SkipVersionCheck == true)
{
throw new InvalidOperationException(
- "Using DynamoDBContextConfig.SkipVersionCheck property with true value is not supported for this operation.");
+ "Using the SkipVersionCheck property with true value is not supported for this operation.");
}
if (!_storageConfig.HasVersion)
diff --git a/sdk/src/Services/DynamoDBv2/Custom/DataModel/TransactWriteConfig.cs b/sdk/src/Services/DynamoDBv2/Custom/DataModel/TransactWriteConfig.cs
index 24aa6f473388..636ec7a6f015 100644
--- a/sdk/src/Services/DynamoDBv2/Custom/DataModel/TransactWriteConfig.cs
+++ b/sdk/src/Services/DynamoDBv2/Custom/DataModel/TransactWriteConfig.cs
@@ -28,11 +28,19 @@ public class TransactWriteConfig : BaseOperationConfig
///
public bool? IgnoreNullValues { get; set; }
+ ///
+ /// Property that directs to skip version checks
+ /// when saving or deleting an object with a version attribute.
+ /// If property is not set, version checks are performed.
+ ///
+ public bool? SkipVersionCheck { get; set; }
+
///
internal override DynamoDBOperationConfig ToDynamoDBOperationConfig()
{
var config = base.ToDynamoDBOperationConfig();
config.IgnoreNullValues = IgnoreNullValues;
+ config.SkipVersionCheck = SkipVersionCheck;
return config;
}
diff --git a/sdk/test/Services/DynamoDBv2/IntegrationTests/DataModelTests.cs b/sdk/test/Services/DynamoDBv2/IntegrationTests/DataModelTests.cs
index a59b32358287..dddbdf37119e 100644
--- a/sdk/test/Services/DynamoDBv2/IntegrationTests/DataModelTests.cs
+++ b/sdk/test/Services/DynamoDBv2/IntegrationTests/DataModelTests.cs
@@ -262,6 +262,49 @@ private async Task TestCompositeHashRangeTable()
Assert.AreEqual(0, gsi4PriorityResults.Count);
}
+ ///
+ /// Tests regression reported in https://github.com/aws/aws-sdk-net/issues/4243 is resolved.
+ ///
+ [TestMethod]
+ [TestCategory("DynamoDBv2")]
+ public async Task TestTransactWrite_SkipVersionCheck()
+ {
+ TableCache.Clear();
+ await CleanupTables();
+ TableCache.Clear();
+
+ CreateContext(DynamoDBEntryConversion.V2, true, true);
+
+ var vp = new VersionedProduct
+ {
+ Id = 1000,
+ Name = "TestProduct",
+ Price = 100
+ };
+ await Context.SaveAsync(vp);
+
+ // Load to get initial version
+ vp = await Context.LoadAsync(vp.Id);
+ Assert.AreEqual(0, vp.Version);
+
+ // Set wrong version - normally would fail with a ConditionalCheck error
+ vp.Version = 9999;
+ vp.Price = 200;
+
+ // With SkipVersionCheck = true, should succeed
+ var transactWrite = Context.CreateTransactWrite(new TransactWriteConfig
+ {
+ SkipVersionCheck = true
+ });
+ transactWrite.AddSaveItem(vp);
+ await transactWrite.ExecuteAsync();
+
+ // Verify update succeeded
+ var updated = await Context.LoadAsync(vp.Id);
+ Assert.AreEqual(200, updated.Price);
+ Assert.AreEqual(9999, updated.Version);
+ }
+
[TestMethod]
[TestCategory("DynamoDBv2")]
public async Task TestContextWithEmptyStringDisabled()
diff --git a/sdk/test/Services/DynamoDBv2/UnitTests/Custom/DataModelOperationSpecificConfigTests.cs b/sdk/test/Services/DynamoDBv2/UnitTests/Custom/DataModelOperationSpecificConfigTests.cs
index 42241a02a5f1..a5b5fc69e03a 100644
--- a/sdk/test/Services/DynamoDBv2/UnitTests/Custom/DataModelOperationSpecificConfigTests.cs
+++ b/sdk/test/Services/DynamoDBv2/UnitTests/Custom/DataModelOperationSpecificConfigTests.cs
@@ -203,7 +203,7 @@ public void TransactWriteConfig()
{
// If this fails because you've added a property, be sure to add it to
// `ToDynamoDBOperationConfig` before updating this unit test
- Assert.AreEqual(5, typeof(TransactWriteConfig).GetProperties().Length);
+ Assert.AreEqual(6, typeof(TransactWriteConfig).GetProperties().Length);
}
[TestMethod]