必要的數據已經被玩弄LINQ,但有一件事我似乎無法讓它做..這裏的情況..可以說你有..過濾與LINQ
public class Job
{
public DateTime? CreatedDate { get; set; }
}
public class Company
{
public string Name { get; set; }
public List<Job> Contract { get; set; }
}
現在我想要做的就是填充公司的名單則只能獲得公司在創建合同..讓說一月..這樣的事情..
String[] MonthName = { "January", "February", "March", "April", "May", "June", "July", "Agust", "September", "October", "November", "December" };
List<Company> Companies = PopulateData();
List<Company> ValidCompany = Companies.Where(CompanyFilter => CompanyFilter.Contract.Any(ContractFilter => MonthName[ContractFilter.CreatedDate.Value.Month - 1] == "January")).ToList();
這工作得很好,但它甚至返回所有合同有些不在一月」。我錯過了一步嗎?
我不能相信這是這麼簡單..我只是忘了分配新的結果.. – Fredrick 2009-04-16 07:56:18