Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
2 different base classes or 1 class or something else?
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
2 different base classes or 1 class or something else?
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01613723
Message ID:
01613723
Vues:
44
Hi everybody,

We have the following base repository class
namespace SysManager.Repository
{
    public abstract class RepositoryBase<T> : IRepository<T> where T : class
    {
        protected readonly ISiriusSqlContext _siriusContext;

        protected readonly IDbSet<T> _dbSet;
        private readonly IExceptionParser _exceptionParser;

        public RepositoryBase(ISiriusSqlContext context)
        {
            _siriusContext = context;
            _dbSet = _siriusContext.Set<T>();
            _exceptionParser = new ExceptionParser();
            
        }
    etc.
Now, I want to be able to optionally enhance it, e.g. I want to be able to pass an extra class but only in some cases, e.g. something like
    public abstract class RepositoryBase<T, TList> : IRepository<T> where T : class, where TList: class
    {
        protected readonly ISiriusSqlContext _siriusContext;

        protected readonly IDbSet<T> _dbSet;
        private readonly IExceptionParser _exceptionParser;

        public RepositoryBase(ISiriusSqlContext context)
        {
            _siriusContext = context;
            _dbSet = _siriusContext.Set<T>();
            _exceptionParser = new ExceptionParser();
            
        }
Will I be able to do something like this and keep all my current declarations the same as this extra TList class I only want to use when supplied?

What are my options here?

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform