{"action":"created","comment":{"url":"https://api.github.com/repos/OData/RESTier/pulls/comments/68171968","id":68171968,"diff_hunk":"@@ -53,48 +56,130 @@ public Expression Process(QueryExpressionContext context)\n             }\n \n             var dataSourceStubReference = context.ModelReference as DataSourceStubModelReference;\n-            if (dataSourceStubReference == null)\n+            if (dataSourceStubReference != null)\n+            {\n+                var entitySet = dataSourceStubReference.Element as IEdmEntitySet;\n+                if (entitySet == null)\n+                {\n+                    return null;\n+                }\n+\n+                var collectionType = entitySet.Type as EdmCollectionType;\n+                var entityType = collectionType?.ElementType.Definition as EdmEntityType;\n+                if (entityType == null)\n+                {\n+                    return null;\n+                }\n+\n+                return AppendOnFilterExpression(context, entityType.Name);\n+            }\n+\n+            var propertyModelReference = context.ModelReference as PropertyModelReference;\n+            if (propertyModelReference != null && propertyModelReference.Property != null)\n+            {\n+                // Could be a single navigation property or a collection navigation property\n+                var propType = propertyModelReference.Property.Type;\n+                var collectoinTypeRef = propType as IEdmCollectionTypeReference;\n+                if (collectoinTypeRef != null)\n+                {\n+                    var collectionType = collectoinTypeRef.Definition as IEdmCollectionType;\n+                    propType = collectionType.ElementType;\n+                }\n+\n+                if (propType.TypeKind() != EdmTypeKind.Entity)\n+                {\n+                    return null;\n+                }\n+\n+                var entityType = propType.Definition as EdmEntityType;\n+                if (entityType == null)\n+                {\n+                    return null;\n+                }\n+\n+                // In case of type inheritance, get the base type\n+                var currentType = entityType;\n+                while (currentType.BaseType != null)\n+                {\n+                    currentType = (EdmEntityType) currentType.BaseType;\n+                }\n+\n+                return AppendOnFilterExpression(context, currentType.Name);\n+            }\n+\n+            return null;\n+        }\n+\n+        private Expression AppendOnFilterExpression(QueryExpressionContext context, string entityTypeName)\n+        {\n+            var methodName = ConventionBasedChangeSetConstants.FilterMethodEntitySetFilter + entityTypeName;\n+            var method = this.targetType.GetQualifiedMethod(methodName);\n+            if (method == null || ! method.IsFamily)\n             {\n                 return null;\n             }\n \n-            var entitySet = dataSourceStubReference.Element as IEdmEntitySet;\n-            if (entitySet == null)\n+            var parameters = method.GetParameters();\n+            if (parameters.Length != 1 ||\n+                parameters[0].ParameterType != method.ReturnType)\n             {\n                 return null;\n             }\n \n-            var returnType = context.VisitedNode.Type\n-                .FindGenericType(typeof(IQueryable<>));\n-            var elementType = returnType.GetGenericArguments()[0];\n-            var methodName = ConventionBasedChangeSetConstants.FilterMethodEntitySetFilter + entitySet.Name;\n-            var method = this.targetType.GetQualifiedMethod(methodName);\n-            if (method != null && method.IsFamily &&\n-                method.ReturnType == returnType)\n+            object apiBase = null;\n+            if (!method.IsStatic)\n+            {\n+                apiBase = context.QueryContext.GetApiService<ApiBase>();\n+                if (apiBase == null ||\n+                    !this.targetType.IsInstanceOfType(apiBase))\n+                {\n+                    return null;\n+                }\n+            }\n+\n+            var returnType = context.VisitedNode.Type.FindGenericType(typeof(IQueryable<>));\n+            var enumerableQueryPara = (object)context.VisitedNode;\n+            Type elementType = null;\n+\n+            if (returnType == null)\n             {\n-                object target = null;\n-                if (!method.IsStatic)\n+                // This means append for properties model reference\n+                var collType = context.VisitedNode.Type.FindGenericType(typeof (ICollection<>));\n+                if (collType == null)\n                 {\n-                    target = context.QueryContext.GetApiService<ApiBase>();\n-                    if (target == null ||\n-                        !this.targetType.IsInstanceOfType(target))\n-                    {\n-                        return null;\n-                    }\n+                    return null;\n                 }\n \n-                var parameters = method.GetParameters();\n-                if (parameters.Length == 1 &&\n-                    parameters[0].ParameterType == returnType)\n+                elementType = collType.GetGenericArguments()[0];\n+                returnType = typeof(IQueryable<>).MakeGenericType(elementType);\n+\n+                enumerableQueryPara = Expression.Call(\n+                    ExpressionHelperMethods.QueryableAsQueryableGeneric.MakeGenericMethod(elementType),","path":"src/Microsoft.Restier.Core/Conventions/ConventionBasedEntitySetProcessor.cs","position":137,"original_position":137,"commit_id":"d1d57cbe7d06476d340172da7dc92701472f1a67","original_commit_id":"d1d57cbe7d06476d340172da7dc92701472f1a67","user":{"login":"lewischeng-ms","id":1402336,"avatar_url":"https://avatars.githubusercontent.com/u/1402336?v=3","gravatar_id":"","url":"https://api.github.com/users/lewischeng-ms","html_url":"https://github.com/lewischeng-ms","followers_url":"https://api.github.com/users/lewischeng-ms/followers","following_url":"https://api.github.com/users/lewischeng-ms/following{/other_user}","gists_url":"https://api.github.com/users/lewischeng-ms/gists{/gist_id}","starred_url":"https://api.github.com/users/lewischeng-ms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lewischeng-ms/subscriptions","organizations_url":"https://api.github.com/users/lewischeng-ms/orgs","repos_url":"https://api.github.com/users/lewischeng-ms/repos","events_url":"https://api.github.com/users/lewischeng-ms/events{/privacy}","received_events_url":"https://api.github.com/users/lewischeng-ms/received_events","type":"User","site_admin":false},"body":"Fix indentation...also wrap line if longer than 120 characters.","created_at":"2016-06-23T03:45:54Z","updated_at":"2016-06-23T03:45:54Z","html_url":"https://github.com/OData/RESTier/pull/446#discussion_r68171968","pull_request_url":"https://api.github.com/repos/OData/RESTier/pulls/446","_links":{"self":{"href":"https://api.github.com/repos/OData/RESTier/pulls/comments/68171968"},"html":{"href":"https://github.com/OData/RESTier/pull/446#discussion_r68171968"},"pull_request":{"href":"https://api.github.com/repos/OData/RESTier/pulls/446"}}},"pull_request":{"url":"https://api.github.com/repos/OData/RESTier/pulls/446","id":74378489,"html_url":"https://github.com/OData/RESTier/pull/446","diff_url":"https://github.com/OData/RESTier/pull/446.diff","patch_url":"https://github.com/OData/RESTier/pull/446.patch","issue_url":"https://api.github.com/repos/OData/RESTier/issues/446","number":446,"state":"open","locked":false,"title":"Add OnFilter support in more case","user":{"login":"chinadragon0515","id":12759740,"avatar_url":"https://avatars.githubusercontent.com/u/12759740?v=3","gravatar_id":"","url":"https://api.github.com/users/chinadragon0515","html_url":"https://github.com/chinadragon0515","followers_url":"https://api.github.com/users/chinadragon0515/followers","following_url":"https://api.github.com/users/chinadragon0515/following{/other_user}","gists_url":"https://api.github.com/users/chinadragon0515/gists{/gist_id}","starred_url":"https://api.github.com/users/chinadragon0515/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chinadragon0515/subscriptions","organizations_url":"https://api.github.com/users/chinadragon0515/orgs","repos_url":"https://api.github.com/users/chinadragon0515/repos","events_url":"https://api.github.com/users/chinadragon0515/events{/privacy}","received_events_url":"https://api.github.com/users/chinadragon0515/received_events","type":"User","site_admin":false},"body":"### Issues\r\n*This pull request fixes issue #71 .*  \r\n\r\n### Description\r\nThis pull request adds more support with onfilter case, and now, onfilter can be supported in these cases,\r\n1. Collection navigation path case\r\n2. $expand case\r\n3. Type cast case\r\n4. $filter case of collection (filtered entity will not be checked for where condition)\r\n5. nest expand case.\r\n\r\nRefer to test cases to see the detail cases covered.\r\n\r\n### Checklist (Uncheck if it is not completed)\r\n- [ x ] Test cases added\r\n- [ x ] Build and test with one-click build and test script passed\r\n\r\n### Additional work necessary\r\nDocument will need to update,\r\n1. Onfilter conversion is based on entity type but not entity set now.\r\n2. Onfilter works in more case beside the base entity set.\r\n","created_at":"2016-06-20T00:28:14Z","updated_at":"2016-06-23T03:45:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f898362ab7826b47c408a5dcf25748b8c07ff973","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/OData/RESTier/pulls/446/commits","review_comments_url":"https://api.github.com/repos/OData/RESTier/pulls/446/comments","review_comment_url":"https://api.github.com/repos/OData/RESTier/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OData/RESTier/issues/446/comments","statuses_url":"https://api.github.com/repos/OData/RESTier/statuses/d1d57cbe7d06476d340172da7dc92701472f1a67","head":{"label":"chinadragon0515:filter","ref":"filter","sha":"d1d57cbe7d06476d340172da7dc92701472f1a67","user":{"login":"chinadragon0515","id":12759740,"avatar_url":"https://avatars.githubusercontent.com/u/12759740?v=3","gravatar_id":"","url":"https://api.github.com/users/chinadragon0515","html_url":"https://github.com/chinadragon0515","followers_url":"https://api.github.com/users/chinadragon0515/followers","following_url":"https://api.github.com/users/chinadragon0515/following{/other_user}","gists_url":"https://api.github.com/users/chinadragon0515/gists{/gist_id}","starred_url":"https://api.github.com/users/chinadragon0515/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chinadragon0515/subscriptions","organizations_url":"https://api.github.com/users/chinadragon0515/orgs","repos_url":"https://api.github.com/users/chinadragon0515/repos","events_url":"https://api.github.com/users/chinadragon0515/events{/privacy}","received_events_url":"https://api.github.com/users/chinadragon0515/received_events","type":"User","site_admin":false},"repo":{"id":50553804,"name":"RESTier","full_name":"chinadragon0515/RESTier","owner":{"login":"chinadragon0515","id":12759740,"avatar_url":"https://avatars.githubusercontent.com/u/12759740?v=3","gravatar_id":"","url":"https://api.github.com/users/chinadragon0515","html_url":"https://github.com/chinadragon0515","followers_url":"https://api.github.com/users/chinadragon0515/followers","following_url":"https://api.github.com/users/chinadragon0515/following{/other_user}","gists_url":"https://api.github.com/users/chinadragon0515/gists{/gist_id}","starred_url":"https://api.github.com/users/chinadragon0515/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chinadragon0515/subscriptions","organizations_url":"https://api.github.com/users/chinadragon0515/orgs","repos_url":"https://api.github.com/users/chinadragon0515/repos","events_url":"https://api.github.com/users/chinadragon0515/events{/privacy}","received_events_url":"https://api.github.com/users/chinadragon0515/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chinadragon0515/RESTier","description":"A turn-key library for building RESTful services","fork":true,"url":"https://api.github.com/repos/chinadragon0515/RESTier","forks_url":"https://api.github.com/repos/chinadragon0515/RESTier/forks","keys_url":"https://api.github.com/repos/chinadragon0515/RESTier/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chinadragon0515/RESTier/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chinadragon0515/RESTier/teams","hooks_url":"https://api.github.com/repos/chinadragon0515/RESTier/hooks","issue_events_url":"https://api.github.com/repos/chinadragon0515/RESTier/issues/events{/number}","events_url":"https://api.github.com/repos/chinadragon0515/RESTier/events","assignees_url":"https://api.github.com/repos/chinadragon0515/RESTier/assignees{/user}","branches_url":"https://api.github.com/repos/chinadragon0515/RESTier/branches{/branch}","tags_url":"https://api.github.com/repos/chinadragon0515/RESTier/tags","blobs_url":"https://api.github.com/repos/chinadragon0515/RESTier/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chinadragon0515/RESTier/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chinadragon0515/RESTier/git/refs{/sha}","trees_url":"https://api.github.com/repos/chinadragon0515/RESTier/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chinadragon0515/RESTier/statuses/{sha}","languages_url":"https://api.github.com/repos/chinadragon0515/RESTier/languages","stargazers_url":"https://api.github.com/repos/chinadragon0515/RESTier/stargazers","contributors_url":"https://api.github.com/repos/chinadragon0515/RESTier/contributors","subscribers_url":"https://api.github.com/repos/chinadragon0515/RESTier/subscribers","subscription_url":"https://api.github.com/repos/chinadragon0515/RESTier/subscription","commits_url":"https://api.github.com/repos/chinadragon0515/RESTier/commits{/sha}","git_commits_url":"https://api.github.com/repos/chinadragon0515/RESTier/git/commits{/sha}","comments_url":"https://api.github.com/repos/chinadragon0515/RESTier/comments{/number}","issue_comment_url":"https://api.github.com/repos/chinadragon0515/RESTier/issues/comments{/number}","contents_url":"https://api.github.com/repos/chinadragon0515/RESTier/contents/{+path}","compare_url":"https://api.github.com/repos/chinadragon0515/RESTier/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chinadragon0515/RESTier/merges","archive_url":"https://api.github.com/repos/chinadragon0515/RESTier/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chinadragon0515/RESTier/downloads","issues_url":"https://api.github.com/repos/chinadragon0515/RESTier/issues{/number}","pulls_url":"https://api.github.com/repos/chinadragon0515/RESTier/pulls{/number}","milestones_url":"https://api.github.com/repos/chinadragon0515/RESTier/milestones{/number}","notifications_url":"https://api.github.com/repos/chinadragon0515/RESTier/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chinadragon0515/RESTier/labels{/name}","releases_url":"https://api.github.com/repos/chinadragon0515/RESTier/releases{/id}","deployments_url":"https://api.github.com/repos/chinadragon0515/RESTier/deployments","created_at":"2016-01-28T04:00:25Z","updated_at":"2016-01-28T04:00:26Z","pushed_at":"2016-06-23T02:30:14Z","git_url":"git://github.com/chinadragon0515/RESTier.git","ssh_url":"git@github.com:chinadragon0515/RESTier.git","clone_url":"https://github.com/chinadragon0515/RESTier.git","svn_url":"https://github.com/chinadragon0515/RESTier","homepage":"http://odata.github.io/RESTier","size":5938,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"OData:master","ref":"master","sha":"1b0dc1e5361911d571d08b27911e5fa3a516a79c","user":{"login":"OData","id":916520,"avatar_url":"https://avatars.githubusercontent.com/u/916520?v=3","gravatar_id":"","url":"https://api.github.com/users/OData","html_url":"https://github.com/OData","followers_url":"https://api.github.com/users/OData/followers","following_url":"https://api.github.com/users/OData/following{/other_user}","gists_url":"https://api.github.com/users/OData/gists{/gist_id}","starred_url":"https://api.github.com/users/OData/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OData/subscriptions","organizations_url":"https://api.github.com/users/OData/orgs","repos_url":"https://api.github.com/users/OData/repos","events_url":"https://api.github.com/users/OData/events{/privacy}","received_events_url":"https://api.github.com/users/OData/received_events","type":"Organization","site_admin":false},"repo":{"id":24577772,"name":"RESTier","full_name":"OData/RESTier","owner":{"login":"OData","id":916520,"avatar_url":"https://avatars.githubusercontent.com/u/916520?v=3","gravatar_id":"","url":"https://api.github.com/users/OData","html_url":"https://github.com/OData","followers_url":"https://api.github.com/users/OData/followers","following_url":"https://api.github.com/users/OData/following{/other_user}","gists_url":"https://api.github.com/users/OData/gists{/gist_id}","starred_url":"https://api.github.com/users/OData/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OData/subscriptions","organizations_url":"https://api.github.com/users/OData/orgs","repos_url":"https://api.github.com/users/OData/repos","events_url":"https://api.github.com/users/OData/events{/privacy}","received_events_url":"https://api.github.com/users/OData/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OData/RESTier","description":"A turn-key library for building RESTful services","fork":false,"url":"https://api.github.com/repos/OData/RESTier","forks_url":"https://api.github.com/repos/OData/RESTier/forks","keys_url":"https://api.github.com/repos/OData/RESTier/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OData/RESTier/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OData/RESTier/teams","hooks_url":"https://api.github.com/repos/OData/RESTier/hooks","issue_events_url":"https://api.github.com/repos/OData/RESTier/issues/events{/number}","events_url":"https://api.github.com/repos/OData/RESTier/events","assignees_url":"https://api.github.com/repos/OData/RESTier/assignees{/user}","branches_url":"https://api.github.com/repos/OData/RESTier/branches{/branch}","tags_url":"https://api.github.com/repos/OData/RESTier/tags","blobs_url":"https://api.github.com/repos/OData/RESTier/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OData/RESTier/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OData/RESTier/git/refs{/sha}","trees_url":"https://api.github.com/repos/OData/RESTier/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OData/RESTier/statuses/{sha}","languages_url":"https://api.github.com/repos/OData/RESTier/languages","stargazers_url":"https://api.github.com/repos/OData/RESTier/stargazers","contributors_url":"https://api.github.com/repos/OData/RESTier/contributors","subscribers_url":"https://api.github.com/repos/OData/RESTier/subscribers","subscription_url":"https://api.github.com/repos/OData/RESTier/subscription","commits_url":"https://api.github.com/repos/OData/RESTier/commits{/sha}","git_commits_url":"https://api.github.com/repos/OData/RESTier/git/commits{/sha}","comments_url":"https://api.github.com/repos/OData/RESTier/comments{/number}","issue_comment_url":"https://api.github.com/repos/OData/RESTier/issues/comments{/number}","contents_url":"https://api.github.com/repos/OData/RESTier/contents/{+path}","compare_url":"https://api.github.com/repos/OData/RESTier/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OData/RESTier/merges","archive_url":"https://api.github.com/repos/OData/RESTier/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OData/RESTier/downloads","issues_url":"https://api.github.com/repos/OData/RESTier/issues{/number}","pulls_url":"https://api.github.com/repos/OData/RESTier/pulls{/number}","milestones_url":"https://api.github.com/repos/OData/RESTier/milestones{/number}","notifications_url":"https://api.github.com/repos/OData/RESTier/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OData/RESTier/labels{/name}","releases_url":"https://api.github.com/repos/OData/RESTier/releases{/id}","deployments_url":"https://api.github.com/repos/OData/RESTier/deployments","created_at":"2014-09-29T02:54:06Z","updated_at":"2016-06-10T19:28:54Z","pushed_at":"2016-06-23T02:30:14Z","git_url":"git://github.com/OData/RESTier.git","ssh_url":"git@github.com:OData/RESTier.git","clone_url":"https://github.com/OData/RESTier.git","svn_url":"https://github.com/OData/RESTier","homepage":"http://odata.github.io/RESTier","size":6416,"stargazers_count":112,"watchers_count":112,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":37,"mirror_url":null,"open_issues_count":116,"forks":37,"open_issues":116,"watchers":112,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OData/RESTier/pulls/446"},"html":{"href":"https://github.com/OData/RESTier/pull/446"},"issue":{"href":"https://api.github.com/repos/OData/RESTier/issues/446"},"comments":{"href":"https://api.github.com/repos/OData/RESTier/issues/446/comments"},"review_comments":{"href":"https://api.github.com/repos/OData/RESTier/pulls/446/comments"},"review_comment":{"href":"https://api.github.com/repos/OData/RESTier/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OData/RESTier/pulls/446/commits"},"statuses":{"href":"https://api.github.com/repos/OData/RESTier/statuses/d1d57cbe7d06476d340172da7dc92701472f1a67"}}}}
{"actor":{"display_login":"lewischeng-ms"}}