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

  • SEARCH
  • Home
  • 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 6910177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:46:51+00:00 2026-05-27T08:46:51+00:00

We have recently developed a library of classes that are used within an MVC3

  • 0

We have recently developed a library of classes that are used within an MVC3 app internally. The MVC3 app uses Autofac to inject the controllers with the required service classes at runtime. The library uses its own set of tables for data storage that may or may not be in the same database as the host application.

The classes follow the dependency injection pattern, and as an example look something like this (yes, you’ve seen it a million times before)…

public class PackageService : ServiceBase, IPackageService
{
    private readonly IRepository _db;
    private readonly IClientService _clientSvc;

    public PackageService(IRepository db, IClientService clientService)
    {
        _db = db;
        _clientSvc = clientService;
    }

    public ServiceResult<IEnumerable<Package>> FindPackagesBy(string searchTerm, out int totalRecords, int pageSize, int pageIndex)
    {
        //...
    }

    public ServiceResult<Package> GetPackage(string packageRef)
    {
        //...
    }
}

We would like to consume these classes within modules that run in Orchard CMS. From what i have read on how orchard works it would seem that i need to decorate each class that i intend to use within Orchard with the IDependency interface – which doesnt really seem like a great idea considering this will create a dependency on orchard itself. Our classes manage their own transactions / unit of work, so do not need to be governed by orchards own transaction mechanism. Is this possible? or are we faced with making Orchard specific implementations of our existing library?

Would be good to hear from anyone who has been through this already.

  • 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-27T08:46:52+00:00Added an answer on May 27, 2026 at 8:46 am

    Figured this out myself…

    Within the module that consumes the ‘external library’ you create an Autofac folder, and add a class that inherits from the Autofac Module and add your bindings in there (this is standard procedure for setting up bindings in Autofac) – Orchard will discover this at runtime and inject your module controllers with the required dependencies.

    However, the calls to the external library are included within the request transaction by default, as this is how orchard works. Because my library was calling SQL Server via EF4 i was getting an exception ‘MSDTC is unavailable on ‘. You need to explicitly state that you do not want these operations included in the transaction, so your controller ends up looking like this…

    [Themed]
    public class HomeController : Controller
    {
        /* this service is from the external library, 
        which calls its own database */
        private readonly IPackageService _packageSvc;
    
        /* this dependency is injected, based upon the bindings
        i specified within the Autofac folder at module level */
        public HomeController(IPackageService packageService)
        {
            _packageSvc = packageService;
        }
    
        public ActionResult Index()
        {
            /* wrap the external lib call so it avoids inclusion
            within the orchard request transaction */
            using (new TransactionScope(TransactionScopeOption.Suppress))
            {
                var package = _packageSvc.GetPackage();
                var model = new HomePageModel()
                {
                    Package = package
                };
                return View("ShowPackage", model);
            }
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a system that we have recently developed - a web application over
I have recently started to explore the way that the C++ runtime library is
i have recently developed a list program in android in which there is an
I'm trying to write an ASM version of a Java app I developed recently,
I have an old (around 5 years) enterprise application that I manage. Recently we
I have a brief conceptional question: Recently, I started to develop an app in
Good Days, I have recently developed a web application in ASP.NET for a marketer
I am a beginner in extension development. I have recently developed a chrome extension
I have a MVC3 Web Application project that I develop and publish from Visual
I'm new to this group but have recently developed a taste for c#. Now

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.