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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:35:25+00:00 2026-05-14T05:35:25+00:00

How should I properly implement data access in my custom model binders? Like in

  • 0

How should I properly implement data access in my custom model binders?

Like in controllers I use IContentRepository and then have it create an instance of its implementing class in constructor. So I have everything ready for incorporating IoC (DI) at a later stage.

Now I need something similar in model binder. I need to make some DB lookups in the binder. I’m thinking of doing it the same way I do it in controllers but I am open to suggestion.

This is a snippet from one of my controllers so you can imagine how I’m doing it in them:

        public class WidgetZoneController : BaseController
        {
// BaseController has IContentRepository ContentRepository field
            public WidgetZoneController() : this(new XmlWidgetZoneRepository())
            {
            }

            public WidgetZoneController(IContentRepository repository)
            {
                ContentRepository = repository;
            }
    ...
  • 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-14T05:35:26+00:00Added an answer on May 14, 2026 at 5:35 am

    Because the binder typically bind an entity, you don’t need a specific repository like IContentRepository, indeed IRepository<T> will be good to get the entity.

    To instantiate the IRipository you can use something like that:

    var repositoryType = typeof (IRepository<>).MakeGenericType(entityType);
    

    I suggest you take a look on the CodeCampServer implementation of entities binder, over here:

    http://code.google.com/p/codecampserver/source/browse/trunk#trunk/src/UI/Binders/Entities

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

Sidebar

Related Questions

I'm working on a project where I have to take data from one source
I've my own class which should do the request and the data processing (parsing).
Ok, So I have tried to implement a coverflow found on codeplex http://silverlightcoverflow.codeplex.com/ I
I am trying to use MVVM in my WPF application which displays data from
Is there any way to get interface to play along with custom namespace? Example
I'm wondering how to best implement a property (here, LatestRequest ) which is read-only,
The application uses ADO.NET to invoke sprocs for nearly every database operation. Some of
Here I need to cache some entites, for example, a Page Tree in a
I'm trying to add a search box to a master page in an ASP.Net
I'm getting an NPE for my EntityManager and can't figure out why - can

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.