In next example, the persistence to the database will not be executed.

C#:
  1. IBinaryAssetStructureRepository rep = new BinaryAssetStructureRepository();
  2. var userDto = new UserDto { id = 3345 };
  3. var dto = new BinaryAssetBranchNodeDto("name", userDto, userDto);
  4. using (var scope1 = new TransactionScope())
  5. {
  6.     using (var scope2 = new TransactionScope())
  7.     {
  8.         //Persist to database
  9.         rep.CreateRoot(dto, 1, false);
  10.         scope2.Complete();
  11.     }
  12.     scope1.Dispose();
  13. }
  14. dto = rep.GetByKey(dto.id, -1, false);

scope1.Dispose(); is not necessary in this example, but I added it for clearance.