Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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();
- List<Company> ValidCompany = (
- from c in Companies
- let janContracts = c.Contracts
- .Where(con => MonthName[con.CreatedDate.Value.Month - 1] == "January")
- where janContracts.Any()
- select new Company
- {
- Name = c.Name,
- Contracts = janContracts.ToList()
- }).ToList();
- var janCompanies = Companies.Select(c=>
- new Company
- {
- Name = c.Name,
- Contracts = c.Contracts
- .Where(con => MonthName[con.CreatedDate.Value.Month - 1] == "January")
- .ToList()
- });
- List<Company> ValidCompany = janCompanies
- .Where(c=>c.Contracts.Any())
- .ToList();
- var qry = from company in Companies
- from contract in company.Companies
- where contract.CreatedDate.Value.Month == ... etc
- select new {Company = company, Contract = contract};
Add Comment
Please, Sign In to add comment