8,736
社区成员
发帖
与我相关
我的任务
分享
public IEnumerable<Summary> TotalSummary
{
get
{ // this._source为EntityList<T>
if (this._source.Source == null)
return null;
else
return this._source.Source.GroupBy(y => y.Phone.Model)
.Select(z => new Summary { Model = z.Key, Count = z.Count() });
}
}
void OnLoadEmployeesCompleted(LoadOperation<Employee> lo)
{
IsBusy = false;
if (lo.HasError)
{
lo.MarkErrorAsHandled();
MessageBox.Show(lo.Error.Message);
}
else if (!lo.IsCanceled)
{
foreach (var ent in lo.Entities)
{
//如果影响统计结果的属性改变,则RaisePropertyChanged("TotalSummary");
ent.PropertyChanged += (s, e) => { if(e.PropertyName == "PhoneId") RaisePropertyChanged(()=>this.TotalSummary); };
}
this._source.Source = lo.Entities;
if (lo.TotalEntityCount != -1)
{
this._view.SetTotalItemCount(lo.TotalEntityCount);
RaisePropertyChanged(() => this.TotalSummary);
}
}
}
void OnLoadEmployeesCompleted(LoadOperation<Employee> lo)
{
IsBusy = false;
if (lo.HasError)
{
lo.MarkErrorAsHandled();
MessageBox.Show(lo.Error.Message);
}
else if (!lo.IsCanceled)
{
// 设置DomainCollectionView的source部分,即EntityList<Employee>的Source属性。
this._source.Source = lo.Entities;
if (lo.TotalEntityCount != -1)
{
this._view.SetTotalItemCount(lo.TotalEntityCount);
//为表现层统计图控件提供数据
TotalSummary = lo.Entities
.GroupBy(x => x.Phone.Model)
.Select(y => new Summary{ Model = y.Key, Count = y.Count() });
}
}
}
public class Summary
{
public string Model { get; set; }
public int Count { get; set; }
}
private IEnumerable<Summary> _totalSummary;
// TotalSummary绑定到View中的visifire图表控件上。
public IEnumerable<Summary> TotalSummary
{
get
{
if (_totalSummary == null)
_totalSummary = new List<Summary>();
return _totalSummary;
}
set
{
_totalSummary = value;
RaisePropertyChanged(() => this.TotalSummary);
}
}