fork download
  1. var includeState = string.IsNullOrEmpty(state);
  2. var lstSkillIds = new List<int>(){1,28};
  3. var includeSkill = lstSkillIds.Count <= 0;
  4. //Query to search all directory users for matching city and last name
  5. var advisors = (from directoryObj in PersonDirectories
  6. from user in directoryObj.Users
  7. from address in user.Address
  8. let skills = user.UserSkills
  9. where (directoryId == 0 || directoryObj.PersonDirectoryId == directoryId)
  10. && user != null
  11.  
  12. //Apply where clause for State filter if state is provided
  13. && ((address != null && !string.IsNullOrEmpty(address.CountryCode)
  14. && (address.CountryCode.ToLower() == country.ToLower()
  15. && (includeState || (!string.IsNullOrEmpty(address.Province)
  16. && address.Province.ToLower() == state.ToLower())))))
  17.  
  18. // add filter to get users with skills given in lstSkillIds
  19. && ( includeSkill || !lstSkillIds.Except(user.UserSkills.Select(u => u.UserSkillId)).Any())
  20. //Get unique search results
  21. group user by new
  22. {
  23. user.PublicId,
  24. address
  25. }
  26. into userGroup
  27.  
  28. select new DirectoryUserObject
  29. {
  30. PublicId = userGroup.Key.PublicId,
  31. Profile = userGroup.FirstOrDefault().Profile,
  32. Address = userGroup.Key.address,
  33. DirSubscription = (int) userGroup.FirstOrDefault().Profile.DirSubscription
  34. });
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty