I am not sure how to ask my question, so I will write a few lines of code ...
I have an abstract base class AbstractRepository like this:
public abstract class AbstractRepository : IGenericRepository
{
protected ISession Session
{
get
{
return Startup.SessionFactory.GetCurrentSession();
}
}
//More code left out for clarity
}
A concrete class that implements the abstract class, AbstractRepository :
public class AccommodationRepository : AbstractRepository
{
// Allow the Session property to be returned from the base class.
public ISession Session => base.Session;
// Which I understand to be the same as the line below:
// public ISession session { get { return base.Session; } }
public async Task<EPICCard> GetByCardNumber(long epicCardId)
{
var session = Session;
CancellationTokenSource token = new CancellationTokenSource();
//Do stuff - not important for now.
return theQueryTask.Result;
}
}
Re-Sharper suggests the following change for the line:
public ISession Session => base.Session;
TO
public new ISession Session => base.Session;
Which one would should I use and why?
Can someone perhaps explain the reasoning for one over the other? Not sure if this is a lack of understanding of
- OOP,
- NHibernate plumbing
- Or both?
What is the reasoning for creating a 'new' ISession?