Guest User

Untitled

a guest
Jun 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. public class Job
  2. {
  3. public DateTime? CreatedDate { get; set; }
  4. }
  5.  
  6. public class Company
  7. {
  8. public string Name { get; set; }
  9. public List<Job> Contract { get; set; }
  10. }
  11.  
  12. String[] MonthName = { "January", "February", "March", "April", "May", "June", "July", "Agust", "September", "October", "November", "December" };
  13.  
  14. List<Company> Companies = PopulateData();
  15. List<Company> ValidCompany = Companies.Where(CompanyFilter => CompanyFilter.Contract.Any(ContractFilter => MonthName[ContractFilter.CreatedDate.Value.Month - 1] == "January")).ToList();
  16.  
  17. List<Company> ValidCompany = (
  18. from c in Companies
  19. let janContracts = c.Contracts
  20. .Where(con => MonthName[con.CreatedDate.Value.Month - 1] == "January")
  21. where janContracts.Any()
  22. select new Company
  23. {
  24. Name = c.Name,
  25. Contracts = janContracts.ToList()
  26. }).ToList();
  27.  
  28. var janCompanies = Companies.Select(c=>
  29. new Company
  30. {
  31. Name = c.Name,
  32. Contracts = c.Contracts
  33. .Where(con => MonthName[con.CreatedDate.Value.Month - 1] == "January")
  34. .ToList()
  35. });
  36. List<Company> ValidCompany = janCompanies
  37. .Where(c=>c.Contracts.Any())
  38. .ToList();
  39.  
  40. var qry = from company in Companies
  41. from contract in company.Companies
  42. where contract.CreatedDate.Value.Month == ... etc
  43. select new {Company = company, Contract = contract};
Add Comment
Please, Sign In to add comment