我使用的是List / IEnumerable,但是需要从名为ChildInfo的类填充属性,我似乎无法将数据集中的数据导入到我的ChildInfo属性类中,这要提前了解这一点。
public ChildInfo GetScreenData(string pCert, string pScreen)
{
DataSet dataSet = _WCFClient.Get_Screen_Data(pCert, pScreen);
ChildInfo childinfo = (from c in dataSet.Tables[0]
select new ChildInfo()
{
FirstName = c[0] == DBNull.Value ? "" : c[0].ToString(),
MiddleName = c[1] == DBNull.Value ? "" : c[1].ToString(),
LastName = c[2] == DBNull.Value ? "" : c[2].ToString(),
Suffix = c[3] == DBNull.Value ? "" : c[3].ToString(),
ChildNotNamed = c[4] == DBNull.Value ? false : (bool)c[4],
Sex = c[5] == DBNull.Value ? "" : c[5].ToString(),
DOB = c[6] == DBNull.Value ? "" : c[6].ToString(),
Hour = c[7] == DBNull.Value ? "" : c[7].ToString(),
Minute = c[7] == DBNull.Value ? "" : c[7].ToString(),
CountryBirth = c[9] == DBNull.Value ? "" : c[9].ToString(),
CityBirth = c[10] == DBNull.Value ? "" : c[10].ToString()
});
return childinfo;
}