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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:59:08+00:00 2026-05-26T07:59:08+00:00

So i think i maybe over-complicating things in my implementation, but here’s what i’m

  • 0

So i think i maybe over-complicating things in my implementation, but here’s what i’m doing:

  1. I want my database represented by IRepository
  2. SQLRepository is a concrete implementation of IRepository.
  3. I want all Tables in the Database represented by ITable.
  4. I have a table called Items, which is represented by ItemsTable.
  5. Each record in Items Table is represented by IItem.
  6. Item is a concrete implementation of IItem.

Now my problem is, in my program when i want to use List items = repository.Items.List(); it won’t compile because in ItemsTable the implementation of ITable return IList and not List. I could return IList but i do want to work with a concrete List of Items.

What can i do better?

 public interface ITable
    {
        IList<IItem> List();
        bool Add(IItem item);
        bool Delete(long itemId);
        bool Find(long itemId);
    }

public class ItemsTable : ITable
{
    public IList<IItem> List()
    {
        IList<IItem> items = GetItems(); // GetItems return List<Item>, Item implements IItem.
        return items;
    }

   .....
   ...
   ..
}

public class SQLRepository : IRepository
{
    ITable items = new ItemsTable();

    public ITable Items
    {
        get { return items; }
    }
}


    static void Main(string[] args)
    {
        var repository = new SQLRepository();
        List<Item> items = repository.Items.List();
    }
  • 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-26T07:59:09+00:00Added an answer on May 26, 2026 at 7:59 am

    The best would be changing your interface to:

    public interface ITable<TItem>
        where TItem : IItem
    {
        IList<TItem> List();
        bool Add(TItem item);
        bool Delete(long itemId);
        bool Find(long itemId);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think I may be way in over my head here... I'm using a
Maybe my memory has gone completely wacko, but I think I remember that declaring
I don't think this is possible but maybe someone knows a way to achieve
I may have the wrong pattern here, but I think it's a fair topic.
I think this is a defered execution issue, but maybe i am missing the
Maybe an over elaborate title. Basically think of an email inbox. I have a
Does anyone know off a way or maybe think its possible to connect Node.js
Is there such a thing? Maybe there should be, I don't think Microsoft built
http://pastebin.com/mYk8M038 here is what I have so far... I think it may be something
I think my question may be a duplicate, but I do not know what

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.