【发布时间】:2013-03-12 09:16:39
【问题描述】:
我有员工实体
public class Employee
{
public Employee();
public int BossId { get; }
public int BossUserId { get; }
public string CostCentre { get; }
public int CostCentreId { get; }
public string Department { get; }
public int DepartmentId { get; }
public string Designation { get; }
public int DesignationId { get; }
public string EmailAddress { get; }
public int EmployeeId { get; }
public string FirstName { get; }
public string FullName { get; }
public string LastName { get; }
public string LoginId { get; }
public int UserId { get; }
public override string ToString();
}
我想在另一个实体中使用所有这些属性并为它们赋值。
我的另一个实体是
public class UserRoles
{
public UserRoles()
{
}
public int UserRoleId { get; set; }
public long EmpUserId { get; set; }
public int RoleId { get; set; }
public DateTime AddedOn { get; set; }
public long AddedBy { get; set; }
public long ModifiedBy { get; set; }
public DateTime ModifiedOnd { get; set; }
}
如果我创建 Employee 类的属性,我无法为其赋值。而且我不能像在某些 dll 中那样更改 Employee 类。
有什么方法可以覆盖它或继承这些属性并为其赋值?
【问题讨论】:
-
从员工继承?
public class UserRoles : Employee。您将拥有所有属性,但这很奇怪 - 用户角色不是员工。顺便说一句,我不明白为什么你不能使用Employee类型的属性 -
是的,但我无法为 Employee 的属性赋值
-
我没有使用 Employee 类型的属性,因为我还想要 UserRole 的属性
-
为什么不能为 Employee 的属性赋值?我看不出有什么原因
-
因为没有二传手。
标签: c#