Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
2 different base classes or 1 class or something else?
Message
De
16/01/2015 11:29:41
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
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:
01613742
Vues:
38
>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?

Don't see where you're using (or want to use) TList in the above but there shouldn't be a problem. Are you getting one ?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform