Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6037851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:08:02+00:00 2026-05-23T06:08:02+00:00

Having worked with Spring MVC for JAVA, I’ve gotten used to having @Transactional behaviour

  • 0

Having worked with Spring MVC for JAVA, I’ve gotten used to having @Transactional behaviour being applied in the service layer which works fabulously well with Hibernate DAOs.
Now that I’m faced with a similar challenge in a project which is based on LINQ to SQL ORM, I see that all transactions are taking places within DAOs ( i.e. using (DC dc = new DC() { dc.submitChanges()}

How do you remove transaction logic from DAOs and bring it to the service layer in ASP.NET MVC LINQ2SQL project?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:08:03+00:00Added an answer on May 23, 2026 at 6:08 am

    It worked fabulously because Spring MVC had Hibernate’s Session and SessionFactory registered and dealt with creating and committing transaction. You can do it in .NET as well but you must do it yourselves. There is no prepared integration of all these tools like Spring MVC provides to Java. You generally need to inject DataContext instance into service layer instead of creating it manually.

    What you call service layer? For me the service layer is a model. In such case the stuff is mostly outside of ASP.NET MVC – there is a way how to create attribute for controller’s action in ASP.NET MVC (custom filters) but that is not a service layer. If you want custom transactional attribute for service layer it mostly means Aspect oriented programming (AOP).

    What are your choices? Select good IoC container which supports AOP – fore example Windsor Castle, Spring.NET, Unity 2.0 or use PostSharp for AOP. The easy way to make transactional AOP attribute is just creating TransactionScope before the annotated method is executed and Complete the scope after the annotated method is executed. But that is not what you want because you will still have to create DataContext instance and call SubmitChanges. You need AOP attribute which will create DataContext instance store it somewhere and execute annotated method. The method will be able to load stored context instance and use it. Once the method finishes the AOP attribute will call SubmitChanges. The only problem is where to store the context instance and how to retrieve it – I believe Spring MVC uses Spring internally for this and provides the whole infrastructure but in .NET you will have to write it – in case of Web app. you will have to store the context in HttpContext.Items.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After having worked in MVC for a few months, I'm back in a previously
I have just started using StructureMap, having previously worked with Spring.Net. I love the
Having worked for Java for 7 years I'm now moving into a project in
This is an example of the string that's being worked with: xxxxxx[xxxxxx][7][xxxxxx][9][xxxxxx] I'm having
I have a simple question. Coming from a java background and having worked extensively
Having worked with Classic ASP for about 2 years now by creating a few
I'm relatively familiar with the concepts of DI/IOC containers having worked on projects previously
Having read the threads Is SqlCommand.Dispose enough? and Closing and Disposing a WCF Service
I java code, I am having a string name = örebro; // its a
I'm currently working with EF4 and asp.net mvc 3 and I'm certainly having some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.