In next example, the persistence to the database will not be executed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | IBinaryAssetStructureRepository rep = new BinaryAssetStructureRepository(); var userDto = new UserDto { id = 3345 }; var dto = new BinaryAssetBranchNodeDto("name", userDto, userDto); using (var scope1 = new TransactionScope()) { using (var scope2 = new TransactionScope()) { //Persist to database rep.CreateRoot(dto, 1, false); scope2.Complete(); } scope1.Dispose(); } dto = rep.GetByKey(dto.id, -1, false); |
scope1.Dispose(); is not necessary in this example, but I added it for clearance.