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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:05:39+00:00 2026-06-04T17:05:39+00:00

EDIT: After @mattytommo’s help in isolating the root-cause of the error, I discovered that

  • 0

EDIT: After @mattytommo’s help in isolating the root-cause of the error, I discovered that the IStatementRepository.cs file was not included in the project. Including it in the project resolved this case.

I am trying to implement a repository on my controller ( with some Dependency Injection thrown in), but I’m bumping into a wall. I have an IStatementRepository defined, But, when I try to create a constructor with an IStatementRepository parameter for DI purposes, I get the following errors:

The type or namespace name 'IStatementRepository' does not 
exist in the namespace 'StatementsApplication.Models' (are 
you missing an assembly reference?) 

The type or namespace name 'IStatementRepository' could 
not be found (are you missing a using directive or an 
assembly reference?)    

'StatementsApplication.Controllers.StatementController' 
does not contain a definition for 'IStatementRepository' 
and no extension method 'IStatementRepository' accepting a 
first argument of type 
'StatementsApplication.Controllers.StatementController' 
could be found (are you missing a using directive or an 
assembly reference?)

Here’s the block of code where the errors are generated:

using StatementsApplication.Models;

namespace StatementsApplication.Controllers
{
    public class StatementController : Controller
    {
        public StatementsApplication.Models.IStatementRepository _repo;

        private DALEntities db = new DALEntities();

        public StatementController(IStatementRepository repository)
        {
            this.IStatementRepository = repository;
        }

        // additional controller actions here
    }
}

And here is the entire contents of IStatementRepository.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using StatementsApplication.DAL;

namespace StatementsApplication.Models
{
    public interface IStatementRepository    {
        IEnumerable<Statement> findAll();
        IEnumerable<Statement> findByMerchantID(int id);
        Statement findByID(int id);
        Statement createStatement(Statement stmt);
        int saveChanges();
        void deleteStatement(int id);

    }
}

I can’t see why I can’t utilize an interface here. All the examples I’m following seem to be using this general patter, so I expect I’m just missing something simple.

I will be very grateful for your input.

  • 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-04T17:05:40+00:00Added an answer on June 4, 2026 at 5:05 pm

    Your constructor is a little off, you’re trying to do this.IStatementRepository, yet the variable is this._repo. Those errors are because Visual Studio is telling you there isn’t a variable called IStatementRepository inside this (your controller) :).

    Try this:

    using StatementsApplication.Models;
    
    namespace StatementsApplication.Controllers
    {
        public class StatementController : Controller
        {
            public StatementsApplication.Models.IStatementRepository _repo;
    
            private DALEntities db = new DALEntities();
    
            public StatementController(IStatementRepository repository)
            {
                this._repo = repository;
            }
    
            // additional controller actions here
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: After addressing some issues that may or may not have been causing problems,
EDIT: After I modified the web.config and I don't get error that's good.... then
FINAL EDIT: After following the answer from Darin Dimitrov, I have found that the
oo design basics here... Edit: To clarify after first answer - I'm not asking
EDIT: My mistake was that I had a go after the first select statement
EDIT After some more research I found that I cannot use a continuous form
EDIT: After fixing a few issues, the bigger issue that I am having is
I have a variable that is not supposed to change its value after it's
[EDIT] After a lot of digging around, I found out that the problem was
-Edit after closing- I try to install ruby 3 to a Server and that

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.