大家好! 這是我的問題:我如何檢索員工數量? 在的DomainService我:如何計算實體中的元素並通過RIA服務將其發送到ViewModel?
public IQueryable<employee> GetEmployeesCommon()
{
return this.ObjectContext. employees
.Where(t => t. is_record_delete == false)
;
}
public int GetNumberOfAllEmployees()
{
return GetEmployeesCommon()
.Where(t => t.idtypepc >= 2)
.Where(t => t.idtypepc <= 11)
.Count();
}
在DataService的:
public void GetEmployeesAllEmployees(Action<InvokeOperation<int>> getEmployeesCallback)
{
Context.GetNumberOfAllEmployees(getEmployeesCallback, null);
}
並在視圖模型:
public void GetTechusAllPCs()
{
EmployeeDataService.GetEmployeesAllEmployees(getEmployeesCallback);
}
private void getEmployeesCallback(InvokeOperation<int> op)
{
EmpAll = op.Value;
}
private int _empAll;
public int EmpAll
{
get { return _empAll; }
set
{
_empAll = value;
RaisePropertyChanged("EmpAll");
}
}
我打電話GetTechusAllPCs()在LoadData()(畢竟實體檢索)和那麼EmpAll具有正確的值,但是如果員工的更改計數(添加或刪除一個)EmpAll將具有與以前相同的值。我如何獲得實際數據?
有人可以說出了什麼問題嗎?
好的,謝謝,我會試試 – rojorm 2011-03-12 13:23:29