Have been playing around with linq but there is one thing I cant seem to make it do.. here is the situation.. lets say you have..
public class Job
{
public DateTime? CreatedDate { get; set; }
}
public class Company
{
public string Name { get; set; }
public List<Job> Contract { get; set; }
}
Now what I want to do is populate a List of Companies then only get companies with Contracts created in.. lets say January.. something like this..
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();
This works fine, but it returns all Contracts even some which are not in "January". Am I missing a step?