我在名为lst_Patient的列表中收集了患者。
这是我从用户那里获取信息的方法:
public Patient[] GetPatientsBySearchParams(DataPair[] dataPair)
{
//return the array patients that match any of the criteria
//Right Now I ma doing this didn't get any success :
List<Patient> P = new List<Patient>();
P = lst_Patient.FindAll(p => { p.FirstName = dataPair[0].OutputValue.ToString();
p.LastName = dataPair[1].OutputValue.ToString();
return true;
return P.ToArray();
}
点击按钮,我将获取用户在文本框中输入的信息:
private DataPair[] dpair;
private void Button_Click(object sender, RoutedEventArgs e)
{
InvalidSearch.Visibility = Visibility.Collapsed;
SearchResults.Visibility = Visibility.Visible;
dpair = new DataPair[]{
new DataPair { Name = "FirstName", OutputValue = fst_Name.Text },
new DataPair { Name = "LastName", OutputValue = lst_Name.Text },
new DataPair { Name = "DateOfBirth", OutputValue = dob.Text },
new DataPair { Name = "SSN", OutputValue = ssn.Text },
new DataPair { Name = "PracticeNumber", OutputValue = pract_nbr.Text },
new DataPair { Name = "ReferenceNumber", OutputValue = ref_nbr.Text },
new DataPair { Name = "PlaceOfService", OutputValue = pos.Text },
new DataPair { Name = "DateOfService", OutputValue = dos.Text},
new DataPair { Name = "RenderingProvider", OutputValue = rndrng_prov.Text },
new DataPair { Name = "AdmissionDate", OutputValue = admsn_date.Text }
};
this.FetchData();
}
private void FetchData()
{
Patient[] p = client.GetPatientsBySearchParams(dpair);
}
答案 0 :(得分:0)
public Patient[] GetPatientsBySearchParams(DataPair[] dataPair)
{
P = lst_Patient.FindAll(
delegate(Patient tmp){
if(tmp.FirstName = dataPair[0].OutputValue || tmp.LastName = dataPair[1].OutputValue)
return true;
else
return false;
}
);
return P.ToArray();
}
答案 1 :(得分:0)
您应该使用反射来调用名称传递的属性。
p.GetType().GetProperty(dataPair[i].Name).GetValue(p) == dataPair[i].OutputValue;