New Posts New Posts RSS Feed: Transaction in DevForce
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Transaction in DevForce

 Post Reply Post Reply
Author
bala View Drop Down
Groupie
Groupie
Avatar

Joined: 18-Aug-2010
Location: Brazil
Posts: 54
Post Options Post Options   Quote bala Quote  Post ReplyReply Direct Link To This Post Topic: Transaction in DevForce
    Posted: 27-Oct-2010 at 11:20am
Hi
I have to use Transaction.
      private void button1_Click(object sender, RoutedEventArgs e)
        {
            PESSOA pessoa = new PESSOA();
            _em.AddEntity(pessoa);
         }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            PESSOA_EMAIL email = new PESSOA_EMAIL();
            _em.AddEntity(email);
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            PESSOA_TELEFONE telefone = new PESSOA_TELEFONE();
            _em.AddEntity(telefone);
       }
        private void Save_Click(object sender, RoutedEventArgs e)
        {
//// _em.saveAsynco()..            
        }
	Above manner i have to use Transaction Commit and rollback
Any Help
PS: I am using oracle as  database.
 
Thanks	
 


Edited by bala - 27-Oct-2010 at 11:21am
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 29-Oct-2010 at 11:21am
Hi bala,
 
I'm not sure I understand what you need. Can you clarify?
 
In the meantime, you can find some informations about transactions at
and
 
Silvio.
Back to Top
bala View Drop Down
Groupie
Groupie
Avatar

Joined: 18-Aug-2010
Location: Brazil
Posts: 54
Post Options Post Options   Quote bala Quote  Post ReplyReply Direct Link To This Post Posted: 29-Oct-2010 at 11:26am
Hi Sbelini

I went thru  your Example but its not enough to undesrstand me.
I want to save sequentially one by one object if one of object fail due to any reason
I want to roolback it...

for example like power failuare or any techinical  problem..

could you assist me..
thanks
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 29-Oct-2010 at 11:53am

Bala,

By default, saves are transactional, i.e. when you try to save your 3 entities (pessoa, email, telefone), DevForce processes them together as a single unit of work. Either all 3 saves succeed, or they are all rolled back.
 
If I understand, you want to save all 3 entities created (pessoa, email, telefone) in 3 different transactions. If any of them fails, only that particular save is rolled back. If this is the case, you should call Save (or SaveAsync) for each entity (or group of entities you want in a transaction).
 
Please let me know if that's what you are looking for.


Edited by sbelini - 29-Oct-2010 at 12:00pm
Back to Top
bala View Drop Down
Groupie
Groupie
Avatar

Joined: 18-Aug-2010
Location: Brazil
Posts: 54
Post Options Post Options   Quote bala Quote  Post ReplyReply Direct Link To This Post Posted: 29-Oct-2010 at 12:06pm
Hi Silvio

for ex- we have (pessoa,email,telefone) and operation fail on saving telefone
we have to reject changes in pessoa and email too ie rollback in both entities..

I think you got clear view now...


Thanks



Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 29-Oct-2010 at 3:00pm
That's the standard behavior if you simply call
 
_em.SaveChangesAsync(...) //if saving telefone fails, pessoa and email will be rolled back
 
Now, if you want to reject the changes in your entity manager, you need to handle the exception accordingly:
 
_em.SaveChangesAsync(savedArgs => {
    if (savedArgs.HasError) {
      // handle exception - reject changes here
    }
  });
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down