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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:40:56+00:00 2026-05-13T20:40:56+00:00

I have a data provider project to access the database. this is composed by

  • 0

I have a data provider project to access the database. this is composed by various classes (PersonDataProvider, JobDataProvider …)
I want to create an Interface.
Do I have to create an Interface for each class?
I was tempted to create one interface and than inherit on all the classes. This involves making all the projects classes partial and change the classes name…….But i think is not the best solution.
Any suggestion?

  • 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-13T20:40:56+00:00Added an answer on May 13, 2026 at 8:40 pm

    You don’t inherit an Interface you implement it. There’s no need to make a class partial to add an interface to it.

    An interface is a contract that the class subscribes to saying that it will honour the methods described in the interface and will implement them appropriately. For your scenario you’d create a single interface and implement it in your classes, you can then pass the instances of the various accessor classes as instances of the interface.

    For example:

    public interface IDataProvider
    {
        void LoadData();
    }
    

    The data providers would then look as follows:

    public class MyDataProvder1 : IDataProvider
    {
        // Some methods
    
        // Must implement LoadData
        public void LoadData()
        {
            // Do something
        }
    }
    
    public class MyDataProvder2 : IDataProvider
    {
        // Some methods
    
        // Must implement LoadData
        public void LoadData()
        {
            // Do something
        }
    }
    

    You can then pass the objects as IDataProvider as follows:

    IDataProvider DataProviderA = new MyDataProvider1();
    IDataProvider DataProviderB = new MyDataProvider2();
    
    // Call function that expects an IDataProvider
    
    DoSomething(DataProviderA);
    DoSomething(DataProviderB);
    

    …

    public void DoSomething(IDataProvider DataProvider)
    {
        DataProvider.LoadData();
    }
    

    Hopefully that clears it up for you.

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

Sidebar

Ask A Question

Stats

  • Questions 347k
  • Answers 347k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You'll probably get some better answers, but meanwhile consider this:… May 14, 2026 at 6:26 am
  • Editorial Team
    Editorial Team added an answer You'll also get that error if it can't find the… May 14, 2026 at 6:26 am
  • Editorial Team
    Editorial Team added an answer I know of three options: Linq to XML (.NET Framework… May 14, 2026 at 6:26 am

Related Questions

I have a Visual Studio 2008 solution with two projects (a Word-Template project and
I'm working on a CMS as my hobby project. Because I'm not paid for
I have used Access 2003 to develop a frontend to a SQL Server database.
SQL Express 2005 is running locally. I have a project written by another person
I've been experimenting with ASP.Net MVC, and have come across a problem that is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.