I'm writing a module that will allow a manager to delegate reports to his or her direct reports. Managers and Delegates are both instances of Employee:
public class Employee : IPersistable { public virtual string EmployeeId { get; set; } public virtual DateTime AsOfDate { get; set; } public virtual string FirstName { get; set; } public virtual string Middle { get; set; } public virtual string LastName { get; set; } public virtual string CompanyNumber { get; set; } public virtual string JobNumber { get; set; } public virtual string JobTitle { get; set; } public virtual string Division { get; set; } public virtual DateTime EmploymentDate { get; set; } public virtual SupportingData Rate { get; set; } public virtual SupportingData Status { get; set; } public virtual int SalaryGrade { get; set; } public virtual string Email { get; set; } public virtual string SupervisorId { get; set; } public virtual string UserName { get; set; } public virtual IList<Employee> Employees { get; set; } }
The ReportDelegation table has a ManagerId, DelegateId, ReportId, and DateCreated.
My conundrum is whether, in my fluent ReportDelegation class, to go with:
public class ReportDelegation : IPersistable { public virtual Employee Manager { get; set; } public virtual Employee Recipient { get; set; } public virtual ReportInfo ReportInfo { get; set; } public virtual DateTime CreateDate { get; set; } }
OR...
public class ReportDelegation : IPersistable { public virtual string ManagerId { get; set; } public virtual string RecipientId { get; set; } public virtual int ReportId { get; set; } public virtual DateTime CreateDate { get; set; } }
I would rather do it the first way, so that I can pass the entire object around and pull attributes as needed. However, I don't know how to set up the mapping between the defined attributes and the DB columns. The lure of the second method is that all I need is:
public class ReportDelegationMap : ClassMap<ReportDelegation> { public ReportDelegationMap() { CompositeId() .KeyProperty(x => x.ManagerId, "Manager_EmpId") .KeyProperty(x => x.RecipientId, "Delegate_EmpId") .KeyProperty(x => x.ReportId, "ReportID"); Map(x => x.CreateDate) .Column("DateCreated"); } }
Again, I feel like the first way, using object instances, is the better way to do it. If so, how do I map to my DB table?