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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:31:25+00:00 2026-05-27T22:31:25+00:00

I have a series of objects that I have mapped into a database with

  • 0

I have a series of objects that I have mapped into a database with LINQ to SQL. The tables are highly normalized. I’m going to abstract my problem. I have five central entities that I have implemented in the database. I then have a series of other objects which I want to implement one or all of these five entities.

Suppose I am implementing a sort of stadium class (think sports teams). These five entities are the five major sports; Baseball, Basketball, Football, Hockey, Soccer. I want to explicitly implement a class for each stadium.

This is an example, Yankee Stadium has hosted Baseball, Hockey and Football games. I want it to implement each of those 3 interfaces. The StadiumBaseClass is my abstract base class that interfaces with my database. The StadiumBaseClass implements all 5 major sports interfaces. I don’t want to have the same code for implementing the IBaseball interface in all possible stadiums, I want it to be implemented once in StadiumBaseClass.

I this example, I only want to implement 3, is this the best way of doing this? Its sort of singletonish, but not quite?

class YankeeStadium : IBaseball, IHockey, IFootball
{
    StadiumBaseClass _Stadium {get; set;}

   // IBaseball
   public IBaseball.Whatever {get { return _Stadium.Baseball;} }

   // IFootball
   public IFootball.Whatever {get { return _Stadium.Hockey;} }

  // IHockey
   public IHockey.Whatever {get { return _Stadium.Hockey;} }
}  
  • 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-27T22:31:26+00:00Added an answer on May 27, 2026 at 10:31 pm

    Here’s an alternative approach (we have used something similar, but not sure how well it will correspond with your linq implementation):

    Have StadiumBaseClass implement each of the interfaces with base functionality, then expose virtual properties that the implementing classes can use to a) indicate which interfaces it supports and b) alter the default behavior as needed.

    For example, assuming the following interfaces:

        public interface IBaseball
        {
            void Whatever();
        }
        public interface IHockey
        {
            void Whatever();
        }
        public interface IFootball
        {
            void Whatever();
        }
        public interface IBasketball
        {
            void Whatever();
        }
        public interface ISoccer
        {
            void Whatever();
        }
    

    Your base class would look something like:

        public class StadiumBaseClass : IBaseball, IBasketball, IHockey, IFootball, ISoccer
        {
    
            #region IBaseball Members
    
            public virtual bool IBaseballImplemented
            {
                get
                {
                    return false;
                }
            }
    
            void IBaseball.Whatever()
            {
                // Do something
            }
    
            #endregion
    
            #region IBasketball Members
    
            public virtual bool IBasketballImplemented
            {
                get
                {
                    return false;
                }
            }
    
            void IBasketball.Whatever()
            {
                // Do something
            }
    
            #endregion
    
            #region IHockey Members
    
            public virtual bool IHockeyImplemented
            {
                get
                {
                    return false;
                }
            }
    
            void IHockey.Whatever()
            {
                // Do something
            }
    
            #endregion
    
            #region IFootball Members
    
            public virtual bool IFootballImplemented
            {
                get
                {
                    return false;
                }
            }
    
            void IFootball.Whatever()
            {
                // Do something
            }
    
            #endregion
    
            #region ISoccer Members
    
            public virtual bool ISoccerImplemented
            {
                get
                {
                    return false;
                }
            }
    
            void ISoccer.Whatever()
            {
                // Do something
            }
    
            #endregion
        }
    

    Which would leave your individual stadium class as:

        class YankeeStadium : StadiumBaseClass
        {
            public override bool  IBaseballImplemented
            {
                get 
                { 
                    return true;
                }
            }
            public override bool IHockeyImplemented
            {
                get
                {
                    return true;
                }
            }
            public override bool IFootballImplemented
            {
                get
                {
                    return true;
                }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a series of Moose objects that I'm looking to feed to JSON::XS
Right now I have a series of objects that are created using C extensions,
I have a series of large fla files that were being published into swc's
I have a series of objects containing product information that I need to use
I've been struggling with the following problem. I have a series of function objects,
Okay I have a series of objects based on a base class which are
I have a series of datetime objects and would like to calculate the average
I have a series of Extension methods to help with null-checking on IDataRecord objects,
I have a series of functional tests against a web application that correctly run,
We have a series of drop down controls that determine the sort order of

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.