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 7727457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:27:50+00:00 2026-06-01T05:27:50+00:00

I would like to have a datacontext available in every controller: public abstract class

  • 0

I would like to have a datacontext available in every controller:

public abstract class ApplicationController : Controller
    {
        private ProjectDataContext datacontext = new SchoolDataContext();

        protected ProjectDataContext DataContext
        {
            get { return datacontext; }
        }
    }

Controllers:

OhterControllers : ApplicationController

Is it a good idea to inherrit from ApplicationController (better way or pattern?) and is there a way to combinate it with Repository and Unit of work pattern

  • 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-06-01T05:27:51+00:00Added an answer on June 1, 2026 at 5:27 am

    In my opinion, creating a new type of controller for keeping a data it isn’t an idea that a controller was intended to do. A new common controller should contain some common actions, soon.

    Combination of Repository and Unit of work are more appropriate in this case. You can take into account also some IoC container implementation here.

    I will suggest you define some IRepository interface for some CRUD operations. And pass this interface into controller constructor. Where some IoC resolver can provide concreate implementation for this interface. Most of modern IoC realisations (for example, Ninject) can provide you with options like create a single concreate implementation for a whole application or only a request.

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

Sidebar

Related Questions

I'm new to DataBinding but would like to accomplish the following: I have a
I have a custom class that I would like to bind a WPF TreeView
Lets say I have a set of model classes like this: public class Person
I have a class encapsulating a bunch of collections. I would like to bind
So in my project i would like have a nice treeview that has images.
I would like to have a Windows 2003 server fire a script to fire
I would like to have a QMainWindow that can change it's look at runtime,
I would like to have Ajax form in Rails so i'm using form_remote_tag. The
I would like to have the keyboard already displaying when I show my view.
I would like to have an .emacs setting so that tabs are always formed

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.