【发布时间】:2013-12-24 11:20:50
【问题描述】:
试图从服务中获取数据并将其绑定到网格
我在 localitem 中获取数据,错误发生在“foreach”行
任何帮助将不胜感激
private IEnumerable<PersonalIDCheckerMvCKendo.Models.PersonInfo> Getlocalinfo(string personalNO)
{
needsUpdate = false;
using (PersonalInfoServiceClient serviceclient = new PersonalInfoServiceClient())
{
List<PersonalIDCheckerMvCKendo.Models.PersonInfo> personInfo = new List<PersonalIDCheckerMvCKendo.Models.PersonInfo>();
try
{
IEnumerable localItem = serviceclient.GetLocalInfoForPerson(personalNO);
if (localItem != null)
{
foreach (PersonalIDCheckerMvCKendo.Models.PersonInfo dalitem in localItem)
{
personInfo.Add(new PersonalIDCheckerMvCKendo.Models.PersonInfo
{
DocumentSerie = dalitem.DocumentSerie,
DocumentNumber = dalitem.DocumentNumber,
DocumentType = dalitem.DocumentType,
DocumentIssuer = dalitem.DocumentIssuer,
DocumentValidDate = dalitem.DocumentValidDate
});
}
}
return personInfo.ToArray();
}
catch
{
throw;
}
finally
{
serviceclient.Close();
}
}
}
编辑:
GetLocalInfoForPerson 是 PersonalInformation 类型
public partial class PersonalInformation : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged , System.Collections.IEnumerable
【问题讨论】:
-
请显示完整的堆栈跟踪。 (不清楚为什么你有一个毫无意义的
catch块,或者你的问题中有这么多空格......我会修复后者,但请在未来更加注意问题的可读性。)跨度> -
流行语完全是多余的,因此毫无意义。
-
我打算改变catch块,需要先让方法工作
-
问题可能出在 localItem 对象中,并且您没有显示创建它的代码。 IEnumerable 是一个接口,我猜想某些 localItem 类有一个存根,用于枚举引发异常的函数之一。如果您需要帮助,请在此问题中添加更多代码。
标签: c# asp.net-mvc exception notimplementedexception