linq2sql - where to enlist transaction (repository or bll)?

Posted by Caroline Showden on Stack Overflow See other posts from Stack Overflow or by Caroline Showden
Published on 2010-03-25T13:16:20Z Indexed on 2010/03/29 21:03 UTC
Read the original article Hit count: 542

My app uses a business layer which calls a repository which uses linq to sql.

I have an Item class that has an enum type property and an ItemDetail property.

I need to implement a delete method that:

(1) always delete the Item (2) if the item.type is XYZ and the ItemDetail is not null, delete the ItemDetail as well.

My question is where should this logic be housed?

If I have it in my business logic which I would prefer, this involves two separate repository calls, each of which uses a separate datacontext. I would have to wrap both calls is a System.Transaction which (in sql 2005) get promoted to a distributed transaction which is not ideal.

I can move it all to a single repository call and the transaction will be handled implicitly by the datacontext but feel that this is really business logic so does not belong in the repository.

Thoughts?

Carrie

© Stack Overflow or respective owner

Related posts about repository

Related posts about linq-to-sql