0
我需要一些LINQ查詢的幫助。LINQ查詢 - 從另一個列表中排除一個列表的值
這裏是我的代碼:
private void ReturnSensitivitiesSearchResults()
{
PatientRecord PMR = new PatientRecord();
// Return the list of sensitivities (Ingredient objects), but do not include any where the "SuitableForSensitivityChecking" is false - as we wouldn't want to include ingredients in the list where
// they can't be screened for sensitivities. - This returns an array of Ingredient[]
var ListOfSensitivities = FDBSystem.Navigation.GetIngredientsByName(txtSearchText.Text + "*", sensitivityType).Where(n => n.SuitableForSensitivityChecking != false);
// Return a list of all of the Sensitivities logged on a PatientRecord (which is a list of Ingredient objects)
var PatientSensitivities = PMR.Sensitivities;
// Populate the drug information into the grid control.
this.dgvSearchResults.DataSource = ListOfSensitivities.ToArray();
}
class PatientRecord
{
public List<Ingredient> Sensitivities = new List<Ingredient>();
}
我需要的是一個LINQ語句返回敏感性的名單,但不包括那些在PatientRecord靈敏度名單的人。
我想要做的是列出所有的敏感性,在datagridview控件....用戶然後可以將其中的一個拖放到樹視圖控件,將其添加到PatientRecord Sensitivities列表中。然後,我想讓datagridview刷新敏感信息,減去病人記錄中已有的敏感信息,這樣就不能將相同的敏感信息添加到樹視圖兩次。
希望你能幫上忙。
可能的重複[你會怎麼做一個「不在」查詢與LINQ?](http://stackoverflow.com/questions/183791/how-would-you-do-a-not-in -query與 - LINQ) – Ben