GitHub PullRequestReviewCommentEvent at 2014-11-13 21:29:33
Repository: Mvc
Actor: dougbu
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/aspnet/Mvc/pulls/comments/20324572","id":20324572,"diff_hunk":"@@ -720,6 +721,146 @@ public virtual Task<bool> TryUpdateModelAsync<TModel>([NotNull] TModel model)\n                                                                 bindingContext.ValidatorProvider);\n         }\n \n+        /// <summary>\n+        /// Updates the specified model instance using values from the controller's current value provider\n+        /// and a <paramref name=\"prefix\"/>.\n+        /// </summary>\n+        /// <typeparam name=\"TModel\">The type of the model object.</typeparam>\n+        /// <param name=\"model\">The model instance to update.</param>\n+        /// <param name=\"prefix\">The prefix to use when looking up values in the value provider.</param>\n+        /// <param name=\"includeExpressions\"><see cref=\"Expression\"/>(s) which represent top level properties \n+        /// which need to be included for the current model.</param>\n+        /// <returns><c>true</c> if the update is successful; otherwise, <c>false</c>.</returns>\n+        [NonAction]\n+        public async Task<bool> \n+            TryUpdateModelAsync<TModel>([NotNull] TModel model,\n+                                        string prefix,\n+                                        [NotNull] params Expression<Func<TModel, object>>[] includeExpressions)\n+           where TModel : class\n+        {\n+            if (BindingContextProvider == null)\n+            {\n+                var message = Resources.FormatPropertyOfTypeCannotBeNull(nameof(BindingContextProvider), GetType().FullName);\n+                throw new InvalidOperationException(message);\n+            }\n+\n+            var bindingContext = await BindingContextProvider.GetActionBindingContextAsync(ActionContext);\n+            return await ModelBindingHelper.TryUpdateModelAsync(model,\n+                                                                prefix,\n+                                                                ActionContext.HttpContext,\n+                                                                ModelState,\n+                                                                bindingContext.MetadataProvider,\n+                                                                bindingContext.ModelBinder,\n+                                                                bindingContext.ValueProvider,\n+                                                                bindingContext.ValidatorProvider,\n+                                                                includeExpressions);\n+        }\n+\n+        /// <summary>\n+        /// Updates the specified model instance using values from the controller's current value provider\n+        /// and a <paramref name=\"prefix\"/>.\n+        /// </summary>\n+        /// <typeparam name=\"TModel\">The type of the model object.</typeparam>\n+        /// <param name=\"model\">The model instance to update.</param>\n+        /// <param name=\"prefix\">The prefix to use when looking up values in the value provider.</param>\n+        /// <param name=\"predicate\">>A predicate which can be used to \n+        /// filter properties(for inclusion/exclusion) at runtime.</param>","path":"src/Microsoft.AspNet.Mvc.Core/Controller.cs","position":127,"original_position":127,"commit_id":"d9b48647411209f2822bf3ffdf25ce9edb0e354e","original_commit_id":"d9b48647411209f2822bf3ffdf25ce9edb0e354e","user":{"login":"dougbu","id":6431421,"avatar_url":"https://avatars.githubusercontent.com/u/6431421?v=3","gravatar_id":"","url":"https://api.github.com/users/dougbu","html_url":"https://github.com/dougbu","followers_url":"https://api.github.com/users/dougbu/followers","following_url":"https://api.github.com/users/dougbu/following{/other_user}","gists_url":"https://api.github.com/users/dougbu/gists{/gist_id}","starred_url":"https://api.github.com/users/dougbu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dougbu/subscriptions","organizations_url":"https://api.github.com/users/dougbu/orgs","repos_url":"https://api.github.com/users/dougbu/repos","events_url":"https://api.github.com/users/dougbu/events{/privacy}","received_events_url":"https://api.github.com/users/dougbu/received_events","type":"User","site_admin":false},"body":"either remove \"(for inclusion/exclusion)\" (seems odd to clarify \"filter\") or at least add a space after \"properties\".  I prefer removal.","created_at":"2014-11-13T21:29:33Z","updated_at":"2014-11-13T21:29:33Z","html_url":"https://github.com/aspnet/Mvc/pull/1533#discussion_r20324572","pull_request_url":"https://api.github.com/repos/aspnet/Mvc/pulls/1533","_links":{"self":{"href":"https://api.github.com/repos/aspnet/Mvc/pulls/comments/20324572"},"html":{"href":"https://github.com/aspnet/Mvc/pull/1533#discussion_r20324572"},"pull_request":{"href":"https://api.github.com/repos/aspnet/Mvc/pulls/1533"}}},"pull_request":{"url":"https://api.github.com/repos/aspnet/Mvc/pulls/1533","id":24179601,"html_url":"https://github.com/aspnet/Mvc/pull/1533","diff_url":"https://github.com/aspnet/Mvc/pull/1533.diff","patch_url":"https://github.com/aspnet/Mvc/pull/1533.patch","issue_url":"https://api.github.com/repos/aspnet/Mvc/issues/1533","number":1533,"state":"open","locked":false,"title":"Adding Support for TryUpdateModel using include expressions and predicate","user":{"login":"harshgMSFT","id":6729943,"avatar_url":"https://avatars.githubusercontent.com/u/6729943?v=3","gravatar_id":"","url":"https://api.github.com/users/harshgMSFT","html_url":"https://github.com/harshgMSFT","followers_url":"https://api.github.com/users/harshgMSFT/followers","following_url":"https://api.github.com/users/harshgMSFT/following{/other_user}","gists_url":"https://api.github.com/users/harshgMSFT/gists{/gist_id}","starred_url":"https://api.github.com/users/harshgMSFT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harshgMSFT/subscriptions","organizations_url":"https://api.github.com/users/harshgMSFT/orgs","repos_url":"https://api.github.com/users/harshgMSFT/repos","events_url":"https://api.github.com/users/harshgMSFT/events{/privacy}","received_events_url":"https://api.github.com/users/harshgMSFT/received_events","type":"User","site_admin":false},"body":"Please note the expressions only work at top level today.\r\nconsider the following Model \r\n```c#\r\n   public class User\r\n    {\r\n        [Required]\r\n        public int Id { get; set; }\r\n        public string UserName { get; set; }\r\n\r\n        public Address Address { get; set; }\r\n    }\r\n\r\n    public class Address\r\n    {\r\n        public int Street { get; set; }\r\n        public string State { get; set; }\r\n\r\n        public Country Country { get; set; }\r\n    }\r\n\r\n   public class Country\r\n   {\r\n        public string Name { get; set; }\r\n   }\r\n```\r\nin the above example if the user calls \r\n\r\n```TryUpdateModel(user, \"\", user => user.Address.Country); ```\r\nThis will result into Address and everything under Address\r\nto be included. i.e User.UserName and User.Id get excluded ( because it works at top level), but user.Address.Street and user.Address.State also gets included because we do not support multi level inclusions at this point. \r\nWe can choose to throw if the user writes nested expressions. @yishaigalatzer thoughts?\r\n\r\nHad an offline chat : we agreed to throw.\r\nIssue created to followup #1533 \r\n\r\n","created_at":"2014-11-10T21:37:45Z","updated_at":"2014-11-13T21:29:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5633907d45f42edd27bb4636ecb2269d2ab014af","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aspnet/Mvc/pulls/1533/commits","review_comments_url":"https://api.github.com/repos/aspnet/Mvc/pulls/1533/comments","review_comment_url":"https://api.github.com/repos/aspnet/Mvc/pulls/comments/{number}","comments_url":"https://api.github.com/repos/aspnet/Mvc/issues/1533/comments","statuses_url":"https://api.github.com/repos/aspnet/Mvc/statuses/d9b48647411209f2822bf3ffdf25ce9edb0e354e","head":{"label":"aspnet:TryUpdateModel","ref":"TryUpdateModel","sha":"d9b48647411209f2822bf3ffdf25ce9edb0e354e","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":15126429,"name":"Mvc","full_name":"aspnet/Mvc","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/Mvc","description":"Model view controller framework for building dynamic web sites with clean separation of concerns, including the merged MVC, Web API, and Web Pages w/ Razor.","fork":false,"url":"https://api.github.com/repos/aspnet/Mvc","forks_url":"https://api.github.com/repos/aspnet/Mvc/forks","keys_url":"https://api.github.com/repos/aspnet/Mvc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/Mvc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/Mvc/teams","hooks_url":"https://api.github.com/repos/aspnet/Mvc/hooks","issue_events_url":"https://api.github.com/repos/aspnet/Mvc/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/Mvc/events","assignees_url":"https://api.github.com/repos/aspnet/Mvc/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/Mvc/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/Mvc/tags","blobs_url":"https://api.github.com/repos/aspnet/Mvc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/Mvc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/Mvc/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/Mvc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/Mvc/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/Mvc/languages","stargazers_url":"https://api.github.com/repos/aspnet/Mvc/stargazers","contributors_url":"https://api.github.com/repos/aspnet/Mvc/contributors","subscribers_url":"https://api.github.com/repos/aspnet/Mvc/subscribers","subscription_url":"https://api.github.com/repos/aspnet/Mvc/subscription","commits_url":"https://api.github.com/repos/aspnet/Mvc/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/Mvc/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/Mvc/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/Mvc/issues/comments/{number}","contents_url":"https://api.github.com/repos/aspnet/Mvc/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/Mvc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/Mvc/merges","archive_url":"https://api.github.com/repos/aspnet/Mvc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/Mvc/downloads","issues_url":"https://api.github.com/repos/aspnet/Mvc/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/Mvc/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/Mvc/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/Mvc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/Mvc/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/Mvc/releases{/id}","created_at":"2013-12-12T03:54:00Z","updated_at":"2014-11-13T21:12:47Z","pushed_at":"2014-11-13T20:12:37Z","git_url":"git://github.com/aspnet/Mvc.git","ssh_url":"git@github.com:aspnet/Mvc.git","clone_url":"https://github.com/aspnet/Mvc.git","svn_url":"https://github.com/aspnet/Mvc","homepage":"","size":56344,"stargazers_count":895,"watchers_count":895,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":225,"mirror_url":null,"open_issues_count":275,"forks":225,"open_issues":275,"watchers":895,"default_branch":"dev"}},"base":{"label":"aspnet:dev","ref":"dev","sha":"17e4dd2bf6eafa42f73b03d2038de3f3878a5544","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":15126429,"name":"Mvc","full_name":"aspnet/Mvc","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/Mvc","description":"Model view controller framework for building dynamic web sites with clean separation of concerns, including the merged MVC, Web API, and Web Pages w/ Razor.","fork":false,"url":"https://api.github.com/repos/aspnet/Mvc","forks_url":"https://api.github.com/repos/aspnet/Mvc/forks","keys_url":"https://api.github.com/repos/aspnet/Mvc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/Mvc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/Mvc/teams","hooks_url":"https://api.github.com/repos/aspnet/Mvc/hooks","issue_events_url":"https://api.github.com/repos/aspnet/Mvc/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/Mvc/events","assignees_url":"https://api.github.com/repos/aspnet/Mvc/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/Mvc/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/Mvc/tags","blobs_url":"https://api.github.com/repos/aspnet/Mvc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/Mvc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/Mvc/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/Mvc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/Mvc/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/Mvc/languages","stargazers_url":"https://api.github.com/repos/aspnet/Mvc/stargazers","contributors_url":"https://api.github.com/repos/aspnet/Mvc/contributors","subscribers_url":"https://api.github.com/repos/aspnet/Mvc/subscribers","subscription_url":"https://api.github.com/repos/aspnet/Mvc/subscription","commits_url":"https://api.github.com/repos/aspnet/Mvc/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/Mvc/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/Mvc/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/Mvc/issues/comments/{number}","contents_url":"https://api.github.com/repos/aspnet/Mvc/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/Mvc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/Mvc/merges","archive_url":"https://api.github.com/repos/aspnet/Mvc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/Mvc/downloads","issues_url":"https://api.github.com/repos/aspnet/Mvc/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/Mvc/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/Mvc/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/Mvc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/Mvc/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/Mvc/releases{/id}","created_at":"2013-12-12T03:54:00Z","updated_at":"2014-11-13T21:12:47Z","pushed_at":"2014-11-13T20:12:37Z","git_url":"git://github.com/aspnet/Mvc.git","ssh_url":"git@github.com:aspnet/Mvc.git","clone_url":"https://github.com/aspnet/Mvc.git","svn_url":"https://github.com/aspnet/Mvc","homepage":"","size":56344,"stargazers_count":895,"watchers_count":895,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":225,"mirror_url":null,"open_issues_count":275,"forks":225,"open_issues":275,"watchers":895,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/aspnet/Mvc/pulls/1533"},"html":{"href":"https://github.com/aspnet/Mvc/pull/1533"},"issue":{"href":"https://api.github.com/repos/aspnet/Mvc/issues/1533"},"comments":{"href":"https://api.github.com/repos/aspnet/Mvc/issues/1533/comments"},"review_comments":{"href":"https://api.github.com/repos/aspnet/Mvc/pulls/1533/comments"},"review_comment":{"href":"https://api.github.com/repos/aspnet/Mvc/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/aspnet/Mvc/pulls/1533/commits"},"statuses":{"href":"https://api.github.com/repos/aspnet/Mvc/statuses/d9b48647411209f2822bf3ffdf25ce9edb0e354e"}}}}