我仍然对数据层和业务层应该编码的内容感到困惑。因为一些方法可以在两个主题中实现。例如,我想要两个日期之间的 Employs 或类似的东西。所以我应该在 BL 或 AL 中这样做。
namespace DataLayer
{
public class EmployeRepository : IEmployeRepository
{
public List<Employe> GetList()
{
using (ADON3Entities db = new ADON3Entities())
{
return db.Employes.ToList();
}
}
public List<Employe> GetEmploysBetweenDates(DateTime start, DateTime end)
{
using (ADON3Entities db = new ADON3Entities())
{
return db.Employes.Where(em => em.NaissEmploye >= start && em.NaissEmploye <= end).ToList();
}
}
}
}
或者我应该这样做:
namespace BusinessLayer
{
public static class EmployeServices
{
static IEmployeRepository repository;
static EmployeServices()
{
repository = new EmployeRepository();
}
public static List<Employe> GetList()
{
return repository.GetList();
}
public static List<Employe> GetEmploysBetweenDates(DateTime start, DateTime end)
{
return repository.GetList().Where(em => em.NaissEmploye >= start && em.NaissEmploye <= end).ToList();
}
}
}
并提前感谢任何帮助或参考以了解树层架构!