Guest User

Untitled

a guest
Apr 25th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. if( operatorRole.AllowedOperations.Count == 0 )
  2. {
  3. operatorRole.AllowedOperations.Add( op1 );// all ops (op1-op4) are transient
  4. operatorRole.AllowedOperations.Add( op2 );
  5. }
  6.  
  7. if (administratorRole.AllowedOperations.Count == 0)
  8. {
  9. administratorRole.AllowedOperations.Add(op1);
  10. administratorRole.AllowedOperations.Add(op2);
  11. administratorRole.AllowedOperations.Add(op3);
  12. administratorRole.AllowedOperations.Add(op4);
  13. }
  14. using( var session = factory.OpenSession() )
  15. using( var tx = session.BeginTransaction() )
  16. {
  17. session.Merge(operatorRole);
  18. session.Merge(administratorRole); // <-- tries to insert op1, and op2 for the 2nd time, throws on UNIQUE violation. SaveOrUpdateCopy does the same
  19. tx.Commit();
  20. }
Add Comment
Please, Sign In to add comment