This is a subject that I have given some thought to and just tried to get a POC working but I am getting a bit lost to be honest.
So I have a 3 tiered web app, the traditional DAL, BAL & FE structure for the purpose of this exercise.
The DAL has reference to my DB through Entity Framework and from this we gain access to a single table JobInfo.
The BAL references the DAL project and has this interface:
public interface IJobInfoRepository
{
IEnumerable<JobInfo> SelectAll();
JobInfo SelectByID(string id);
void Insert(JobInfo obj);
void Update(JobInfo obj);
void Delete(string id);
void Save();
}
Then I have this class:
public class JobInfoRepository : IJobInfoRepository
{
public JobInfoRepository()
{
_db = new TestEntities();
}
public JobInfoRepository(TestEntities db)
{
_db = db;
}
private TestEntities _db = null;
public IEnumerable<JobInfo> SelectAll()
{
return _db.JobInfoes.ToList();
}
public JobInfo SelectByID(string id)
{
return _db.JobInfoes.Find(id);
}
public void Insert(JobInfo obj)
{
_db.JobInfoes.Add(obj);
}
public void Update(JobInfo obj)
{
_db.Entry(obj).State = EntityState.Modified;
}
public void Delete(string id)
{
JobInfo existing = _db.JobInfoes.Find(id);
_db.JobInfoes.Remove(existing);
}
public void Save()
{
_db.SaveChanges();
}
}
In my FE project I reference the BAL project. But this is where I'm lost. Without giving FE access to the DAL project and therefore having visibility to my JobInfo entity how can the FE code perform any of the CRUD operations in the BAL project?
Thanks,
Dave