Suppose I am implementing the Repository and Unit Of Work Pattern in my project so that I can unit test my methods. The following are folders of interest inside the project folder
// Core - contains Domain and Repository folders
// Domain folder contains the following classes
public abstract class Account
{
}
public class CheckingAccount:
{
}
public class SavingsAccount:
{
}
Repository folder contains IUnitOfWork interface with the following details
public interface IUnitOfWork:: IDisposable
{
IAccountRepository Accounts{ get; }
ICheckingRepository CheckingAccounts{ get; }
ISavingsRepository SavingsAccounts { get; }
int Complete();
}
// Persistent - contains Repositories folder, CheckingAccountRepository, SavingsAccountRepository, and BankContext class
// I will only focus on the BankContext and UnitOfWork classes
public class UnitOfWork : IUnitOfWork
{
private readonly BankContext _context;
public UnitOfWork(BankContext context)
{
_context = context;
CheckingsAccount = new CheckingRepository(_context);
SavingsAccount = new SavingsRepository(_context);
}
public ICheckingRepository Checkings { get; private set; }
public ISavingsRepository Savingss { get; private set; }
public int Complete()
{
return _context.SaveChanges();
}
public void Dispose()
{
_context.Dispose();
}
}
public class BankContext : DbContext
{
public BankContext()
: base("name=BankContext")
{
this.Configuration.LazyLoadingEnabled = false;
}
public virtual DbSet<Account> Accounts { get; set; }
public virtual DbSet<CheckingAccount> CheckingAccounts { get; set; }
public virtual DbSet<SavingsAccount> SavingsAccounts { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Configurations.Add(new AccountConfiguration());
}
}In the code above, I have an abstract class called Account which serves as the base class for CheckingAccount and SavingsAccount classes.
The code in the Repository folder and Persistent folder above are what my code would look like if all the classes in the Domain folder are concrete classes
The question I would like to ask is since the Account class in the Domain folder is an abstract class, how does it affect the code for Accounts property in the Repository folder and the code in the BankContext class in the Persistent folder.