本文整理汇总了C#中IEmployeeRepository.GetAllEmployees方法的典型用法代码示例。如果您正苦于以下问题:C# IEmployeeRepository.GetAllEmployees方法的具体用法?C# IEmployeeRepository.GetAllEmployees怎么用?C# IEmployeeRepository.GetAllEmployees使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEmployeeRepository
的用法示例。
在下文中一共展示了IEmployeeRepository.GetAllEmployees方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainViewModel
/// <summary>
/// 初始化 MainViewModel 类的新实例。
/// </summary>
/// <param name="unitOfWork">用于协调更改的 UnitOfWork</param>
/// <param name="departmentRepository">用于查询部门数据的存储库</param>
/// <param name="employeeRepository">用于查询雇员数据的存储库</param>
public MainViewModel(IUnitOfWork unitOfWork, IDepartmentRepository departmentRepository, IEmployeeRepository employeeRepository)
{
if (unitOfWork == null)
{
throw new ArgumentNullException("unitOfWork");
}
if (departmentRepository == null)
{
throw new ArgumentNullException("departmentRepository");
}
if (employeeRepository == null)
{
throw new ArgumentNullException("employeeRepository");
}
this.unitOfWork = unitOfWork;
// 生成数据结构以填充应用程序图面的区域
ObservableCollection<EmployeeViewModel> allEmployees = new ObservableCollection<EmployeeViewModel>();
ObservableCollection<DepartmentViewModel> allDepartments = new ObservableCollection<DepartmentViewModel>();
foreach (var dep in departmentRepository.GetAllDepartments())
{
allDepartments.Add(new DepartmentViewModel(dep));
}
foreach (var emp in employeeRepository.GetAllEmployees())
{
allEmployees.Add(new EmployeeViewModel(emp, allEmployees, allDepartments, this.unitOfWork));
}
this.DepartmentWorkspace = new DepartmentWorkspaceViewModel(allDepartments, unitOfWork);
this.EmployeeWorkspace = new EmployeeWorkspaceViewModel(allEmployees, allDepartments, unitOfWork);
// 生成在职时间较长的雇员的非交互列表
List<BasicEmployeeViewModel> longServingEmployees = new List<BasicEmployeeViewModel>();
foreach (var emp in employeeRepository.GetLongestServingEmployees(5))
{
longServingEmployees.Add(new BasicEmployeeViewModel(emp));
}
this.LongServingEmployees = longServingEmployees;
this.SaveCommand = new DelegateCommand((o) => this.Save());
}