我上了一堂Employee
课,每个员工都有一份申请休假的清单。是否可以将列表AppliedLeave
作为[DataMember]
WCF 中的一个?
[DataContract]
public class Employee
{
[DataMember]
public string UserID { get; set; }
[DataMember]
public int EmployeeNumber { get; set; }
[ForeignKey("EmployeeUserID")]
[DataMember]
public List<Leave> AppliedLeave
{
get { return _appliedLeaves; }
set { _appliedLeaves = value; }
}
private List<Leave> _appliedLeaves = new List<Leave>();
...
}
有没有其他方法可以做到这一点?
感谢您对此事的考虑
我扩展我的问题
这是我的假期班:
[DataContract]
public class Leave
{
[Key()]
[DataMember]
public Guid LeaveId { get; set; }
[DataMember]
public string LeaveType { get; set; }
[DataMember]
public DateTime StartDate { get; set; }
[DataMember]
public string EmployeeUserID { get; set; }
}
这显示了 ServiceContract ---->
[ServiceContract]
public interface IEmployeeService
{
[OperationContract]
Employee GetEmployeeByUserId(string userId);
[OperationContract]
void AssignSupervisor(string userId, string supervisorUserId);
[OperationContract]
void DeleteEmployeeByUserId(string userId);
....
}
在客户端应用程序中,
EmployeeServiceClient employeeService = new EmployeeServiceClient();
员工员工 = employeeService.GetEmployeeByUserId(id);
但是当 Employee 从服务中收集时,它显示 Null 表示叶子,
有人可以帮助我吗?我在这里做错了什么?