2
我在名爲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);
}
有一些你需要在你的答案 代替p.FirstName這將是tmp.FirstName做的修改,我想匹配任何條件,而不是&&,使用|| ...謝謝爲答案。 – Malcolm 2010-08-06 10:55:54
@Malcolm固定。而不是一成不變的方法,你可以使用lambda或者difine靜態函數。 – Arseny 2010-08-06 11:05:58