Transaction Attribute + Validation

11 views
Skip to first unread message

Paul Hinett

unread,
Jun 4, 2010, 9:55:24 PM6/4/10
to sharp-arc...@googlegroups.com

Hi,

 

What is the recommended approach for server side validation and the transaction attribute?

 

At the moment I am checking my ModelState for any errors, if any were found then I rollback the transaction and return them back to the entry form.

 

Is there not a more automated way to do this other than having to rollback the transaction manually each time?

 

Paul

Rafael Mueller

unread,
Jun 4, 2010, 10:17:48 PM6/4/10
to sharp-arc...@googlegroups.com
I just changed Transaction attribute so it rollback on ModelError, if you define the attribute like this
[Transaction(RollbackOnModelStateError=true)]

you can check it here

I'll do a pull request with this patch.

Regards,
--
Rafael Mueller


--
You received this message because you are subscribed to the Google Groups "S#arp Architecture" group.
To post to this group, send email to sharp-arc...@googlegroups.com.
To unsubscribe from this group, send email to sharp-architect...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sharp-architecture?hl=en.

Leonardo Rodriguez

unread,
Jun 4, 2010, 10:52:17 PM6/4/10
to sharp-arc...@googlegroups.com
Really nice idea!

2010/6/4 Rafael Mueller <muell...@gmail.com>

Paul Hinett

unread,
Jun 5, 2010, 6:51:58 AM6/5/10
to sharp-arc...@googlegroups.com

That sounds perfect!

Nabeel

unread,
Jun 5, 2010, 11:29:17 PM6/5/10
to S#arp Architecture
Hi Rafael,

Although I do all the validation and transaction manipulation (begin,
commit, rollback) in ApplicationServices, I was wondering if it still
be ok to decorate Actions with
[Transaction(RollbackOnModelStateError=true)] as well, probably just
incase if I miss rollback logic in ApplicationServices ?

Regards,
Nabeel

Rafael Mueller

unread,
Jun 6, 2010, 11:05:10 AM6/6/10
to sharp-arc...@googlegroups.com
Hi Nabeel,

Yes you can. 

TransactionAttribute will always check if currentTransaction.IsActive before trying to commit/rollback.

Regards
--
Rafael Mueller


Reply all
Reply to author
Forward
0 new messages