[Entity folder ]
public class Equipment
{
public int EquipmentID { get; set; }
public string EquipmentCode { get; set; }
public string EquipmentName { get; set; }
public string EquipmentDescription { get; set; }
}
public class Employee
{
public int EmployeeID { get; set; }
public string EmployeeCode { get; set; }
public string EmployeeName { get; set; }
}
public class EquipmentTran
{
public int { get; set; }
public LendDate datetime {get; set; }
public int EmployeeID { get; set; }
public int EquipmentID { get; set; }
public string Side { get; set; }
// IN,OUT
}
[Abstract folder ]
public interface IEquipmentRepository
{
IQueryable<Equipment> Equipments { get; }
}
public interface IEmployeeRepository
{
IQueryable<Employee> Employees { get; }
}
public interface IEquipmentTran
{
IQueryable<EquipmentTran> EquipmentTrans { get; }
}
[Concrete folder ]
public class EFEquipmentRepository : IEquipmentRepository
{
private EFDbContext context = new EFDbContext();
public IQueryable<Equipment> Equipments
{
get { return context.Equipments; }
}
}
public class EFEmployeeRepository : IEmployeeRepository
{
private EFDbContext context = new EFDbContext();
public IQueryable<Employee> Employees
{
get { return context.Employees; }
}
}
public class EFEquipmentTranRepository : IEquipmentTranRepository
{
private EFDbContext context = new EFDbContext();
public IQueryable<EquipmentTran> EquipmentTrans
{
get { return context.EquipmentTrans; }
}
}
public class EFDbContext : DbContext
{
public DbSet<Equipment> Equipments { get; set; }
public DbSet<Employee> Employees { get; set; }
public DbSet<EquipmentTran> EquipmentTrans { get; set; }
}