Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
2 different base classes or 1 class or something else?
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
2 different base classes or 1 class or something else?
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01613723
Message ID:
01613723
Views:
45
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
Next
Reply
Map
View

Click here to load this message in the networking platform