{"action":"created","issue":{"url":"https://api.github.com/repos/SharePoint/sp-dev-docs/issues/3191","repository_url":"https://api.github.com/repos/SharePoint/sp-dev-docs","labels_url":"https://api.github.com/repos/SharePoint/sp-dev-docs/issues/3191/labels{/name}","comments_url":"https://api.github.com/repos/SharePoint/sp-dev-docs/issues/3191/comments","events_url":"https://api.github.com/repos/SharePoint/sp-dev-docs/issues/3191/events","html_url":"https://github.com/SharePoint/sp-dev-docs/issues/3191","id":395003663,"node_id":"MDU6SXNzdWUzOTUwMDM2NjM=","number":3191,"title":"CSOM: cannot ensure multiple users at once","user":{"login":"baywet","id":7905502,"node_id":"MDQ6VXNlcjc5MDU1MDI=","avatar_url":"https://avatars1.githubusercontent.com/u/7905502?v=4","gravatar_id":"","url":"https://api.github.com/users/baywet","html_url":"https://github.com/baywet","followers_url":"https://api.github.com/users/baywet/followers","following_url":"https://api.github.com/users/baywet/following{/other_user}","gists_url":"https://api.github.com/users/baywet/gists{/gist_id}","starred_url":"https://api.github.com/users/baywet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baywet/subscriptions","organizations_url":"https://api.github.com/users/baywet/orgs","repos_url":"https://api.github.com/users/baywet/repos","events_url":"https://api.github.com/users/baywet/events{/privacy}","received_events_url":"https://api.github.com/users/baywet/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-31T16:32:12Z","updated_at":"2018-12-31T16:32:19Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"#### Category\r\n- [ ] Question\r\n- [ ] Typo\r\n- [x] Bug\r\n- [ ] Additional article idea\r\n\r\n#### Expected or Desired Behavior\r\nBeing able to ensure multiple users in a single execute query via the CSOM.\r\n\r\n#### Observed Behavior\r\nEach ensure user needs it's own execute query in order to work properly. This adds unecessary roundtrips which impacts performance.\r\n\r\n#### Steps to Reproduce\r\nUsing CSOM (online) : 16.1.8412.1200 \r\n```CS\r\n// initialize your context here\r\nvar missingUsers = new List<string> { \"user1@contoso.com\", \"user2@contoso.com\"}; //replace by valid users in your tenant\r\n// this doesn't work, accessing something like the email property will give you a prop not initialized exception\r\nvar ensuredUsers = missingUsers.Select(x => siteCollContext.Web.EnsureUser(x));\r\nensuredUsers.ToList().ForEach(x => siteCollContext.Load(x));\r\nawait siteCollContext.ExecuteQueryRetryAsync();\r\n// this works\r\nvar ensuredUsers = new List<User>();\r\nforeach(var missingUser in missingUsers)\r\n{\r\n var user = siteCollContext.Web.EnsureUser(missingUser);\r\n siteCollContext.Load(user);\r\n await siteCollContext.ExecuteQueryRetryAsync();\r\n ensuredUsers.Add(user);\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/SharePoint/sp-dev-docs/issues/comments/450665815","html_url":"https://github.com/SharePoint/sp-dev-docs/issues/3191#issuecomment-450665815","issue_url":"https://api.github.com/repos/SharePoint/sp-dev-docs/issues/3191","id":450665815,"node_id":"MDEyOklzc3VlQ29tbWVudDQ1MDY2NTgxNQ==","user":{"login":"msft-github-bot","id":42388855,"node_id":"MDQ6VXNlcjQyMzg4ODU1","avatar_url":"https://avatars0.githubusercontent.com/u/42388855?v=4","gravatar_id":"","url":"https://api.github.com/users/msft-github-bot","html_url":"https://github.com/msft-github-bot","followers_url":"https://api.github.com/users/msft-github-bot/followers","following_url":"https://api.github.com/users/msft-github-bot/following{/other_user}","gists_url":"https://api.github.com/users/msft-github-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/msft-github-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msft-github-bot/subscriptions","organizations_url":"https://api.github.com/users/msft-github-bot/orgs","repos_url":"https://api.github.com/users/msft-github-bot/repos","events_url":"https://api.github.com/users/msft-github-bot/events{/privacy}","received_events_url":"https://api.github.com/users/msft-github-bot/received_events","type":"User","site_admin":false},"created_at":"2018-12-31T16:32:19Z","updated_at":"2018-12-31T16:32:19Z","author_association":"COLLABORATOR","body":"Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible."}}
{"actor":{"display_login":"msft-github-bot"}}