我有一个数据类,从一个WCF DataService的返回某个对象的Silverlight应用程序被retrurning duplcate行:WCF数据服务查询,似乎在重复的查询
无效ExecuteWipReportQuery(化DataServiceQuery QRY) { 上下文=新StaffKpiServices.HwfStaffKpiEntities(theServiceRoot); qry.BeginExecute(新的AsyncCallback(A => { 尝试 { IEnumerable的结果= qry.EndExecute(一); OnDataLoadingComplete(新WipReportByMonthEventArgs(结果));} 捕获 (异常前) { OnDataLoadingError (ex); } }),null); }
然后视图模型获得这样的结果,并将它们添加到一个观察到的集合:
空隙wipReportDataContainer_DataLoadingComplete(对象发件人,Domain.WipReportByMonthEventArgs E) { Application.Current.RootVisual.Dispatcher.BeginInvoke(( )=> { this.wipReport.Clear(); 字符串s = “”;
foreach (StaffKpiServices.WipReportByMonth r in e.Results)
{
//this.wipReport.Add(r);
//s += r.ClientCode;
this.wipReport.Add(new StaffKpiServices.WipReportByMonth
{
ClientCode = r.ClientCode,
ClientGroup = r.ClientGroup,
ClientName = r.ClientName,
ClientType = r.ClientType,
FinancialYear = r.FinancialYear,
Month = r.Month,
OSDebt = r.OSDebt,
OSDisb = r.OSDisb,
OSOther = r.OSOther,
OSTime = r.OSTime,
OSTotal = r.OSTotal,
PartnerUserName = r.PartnerUserName,
PracName = r.PracName,
Recov = r.Recov,
RecovFees = r.RecovFees,
RecPerc = r.RecPerc,
SicCode = r.SicCode,
SicParentName = r.SicParentName,
StaffName = r.StaffName,
YTDFees = r.YTDFees,
YTDTime = r.YTDTime
});
s += r.ClientCode + " ";
}
string s2 = "";
foreach (var p in this.wipReport)
{
s2 += p.ClientCode + " ";
}
OnPropertyChanged("WipReport");
if (null != LoadComplete)
{
LoadComplete(this, EventArgs.Empty);
}
});
}
一切正常确定,但如果该数据是refres hed两到三次,那么集合retrun包含正确数量的对象,但都具有重复的属性。似乎没有任何理由,这就好像这个foreach没有在集合上工作,但同时又没有返回任何错误。有任何想法吗?