{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5845","repository_url":"https://api.github.com/repos/aspnet/EntityFramework","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5845/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5845/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5845/events","html_url":"https://github.com/aspnet/EntityFramework/issues/5845","id":162006943,"number":5845,"title":"How to extend EF functionality with custom Extension Methods","user":{"login":"pgrm","id":713456,"avatar_url":"https://avatars.githubusercontent.com/u/713456?v=3","gravatar_id":"","url":"https://api.github.com/users/pgrm","html_url":"https://github.com/pgrm","followers_url":"https://api.github.com/users/pgrm/followers","following_url":"https://api.github.com/users/pgrm/following{/other_user}","gists_url":"https://api.github.com/users/pgrm/gists{/gist_id}","starred_url":"https://api.github.com/users/pgrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pgrm/subscriptions","organizations_url":"https://api.github.com/users/pgrm/orgs","repos_url":"https://api.github.com/users/pgrm/repos","events_url":"https://api.github.com/users/pgrm/events{/privacy}","received_events_url":"https://api.github.com/users/pgrm/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aspnet/EntityFramework/labels/type-investigation","name":"type-investigation","color":"0052cc"}],"state":"open","locked":false,"assignee":{"login":"anpete","id":1210944,"avatar_url":"https://avatars.githubusercontent.com/u/1210944?v=3","gravatar_id":"","url":"https://api.github.com/users/anpete","html_url":"https://github.com/anpete","followers_url":"https://api.github.com/users/anpete/followers","following_url":"https://api.github.com/users/anpete/following{/other_user}","gists_url":"https://api.github.com/users/anpete/gists{/gist_id}","starred_url":"https://api.github.com/users/anpete/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anpete/subscriptions","organizations_url":"https://api.github.com/users/anpete/orgs","repos_url":"https://api.github.com/users/anpete/repos","events_url":"https://api.github.com/users/anpete/events{/privacy}","received_events_url":"https://api.github.com/users/anpete/received_events","type":"User","site_admin":false},"assignees":[{"login":"anpete","id":1210944,"avatar_url":"https://avatars.githubusercontent.com/u/1210944?v=3","gravatar_id":"","url":"https://api.github.com/users/anpete","html_url":"https://github.com/anpete","followers_url":"https://api.github.com/users/anpete/followers","following_url":"https://api.github.com/users/anpete/following{/other_user}","gists_url":"https://api.github.com/users/anpete/gists{/gist_id}","starred_url":"https://api.github.com/users/anpete/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anpete/subscriptions","organizations_url":"https://api.github.com/users/anpete/orgs","repos_url":"https://api.github.com/users/anpete/repos","events_url":"https://api.github.com/users/anpete/events{/privacy}","received_events_url":"https://api.github.com/users/anpete/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/aspnet/EntityFramework/milestones/19","html_url":"https://github.com/aspnet/EntityFramework/milestones/1.1.0","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/milestones/19/labels","id":1748298,"number":19,"title":"1.1.0","description":"","creator":{"login":"rowanmiller","id":4741851,"avatar_url":"https://avatars.githubusercontent.com/u/4741851?v=3","gravatar_id":"","url":"https://api.github.com/users/rowanmiller","html_url":"https://github.com/rowanmiller","followers_url":"https://api.github.com/users/rowanmiller/followers","following_url":"https://api.github.com/users/rowanmiller/following{/other_user}","gists_url":"https://api.github.com/users/rowanmiller/gists{/gist_id}","starred_url":"https://api.github.com/users/rowanmiller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rowanmiller/subscriptions","organizations_url":"https://api.github.com/users/rowanmiller/orgs","repos_url":"https://api.github.com/users/rowanmiller/repos","events_url":"https://api.github.com/users/rowanmiller/events{/privacy}","received_events_url":"https://api.github.com/users/rowanmiller/received_events","type":"User","site_admin":false},"open_issues":97,"closed_issues":61,"state":"open","created_at":"2016-05-04T18:23:47Z","updated_at":"2016-07-14T21:51:49Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2016-06-23T19:44:12Z","updated_at":"2016-07-15T19:32:30Z","closed_at":null,"body":"Related to my question on stackoverflow [*How to implement Select For Update in EF Core*](http://stackoverflow.com/questions/37984312/how-to-implement-select-for-update-in-ef-core), I was wondering if it is possible to create custom extension methods in order to modify the executed SQL statement before execution. \r\n\r\nIn my case, I want to let other developers define queries in Linq or Fluent methods, take those select statements and append `FOR UPDATE`, `FOR UPDATE NOWAIT`, or `FOR UPDATE SKIP LOCKED`. Another, and very popular, example is [Entity Framework Extended Library](https://github.com/loresoft/EntityFramework.Extended). A colleague of mine told me, that their approach won't work anymore in EF Core. I didn't have time to investigate it yet and I also hoped for a much simpler solution, something like Linq 2 SQL provides with [DataContext.GetCommand](https://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.getcommand(v=vs.110).aspx) but I'm loosing hope that those solutions exist. \r\n\r\nThat's why I'd like to know, if it is somehow possible to reuse the existing handling of IQueryable from EF Core and extend it with custom features or I should go along and try to define and create a bunch of fluent methods myself instead.\r\n\r\nThanks"},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/comments/233049682","html_url":"https://github.com/aspnet/EntityFramework/issues/5845#issuecomment-233049682","issue_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5845","id":233049682,"user":{"login":"anpete","id":1210944,"avatar_url":"https://avatars.githubusercontent.com/u/1210944?v=3","gravatar_id":"","url":"https://api.github.com/users/anpete","html_url":"https://github.com/anpete","followers_url":"https://api.github.com/users/anpete/followers","following_url":"https://api.github.com/users/anpete/following{/other_user}","gists_url":"https://api.github.com/users/anpete/gists{/gist_id}","starred_url":"https://api.github.com/users/anpete/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anpete/subscriptions","organizations_url":"https://api.github.com/users/anpete/orgs","repos_url":"https://api.github.com/users/anpete/repos","events_url":"https://api.github.com/users/anpete/events{/privacy}","received_events_url":"https://api.github.com/users/anpete/received_events","type":"User","site_admin":false},"created_at":"2016-07-15T19:32:30Z","updated_at":"2016-07-15T19:32:30Z","body":"Interception is built-in to EF Core via our DI system. See https://docs.efproject.net/en/latest/miscellaneous/internals/services.html for details, but the general approach will be to subclass or decorate and existing EF component and register it such that EF will use the custom version.\r\n\r\nNow, the question becomes, where is the best place to inject specific custom logic? For query, there are several candidates and which is best depends on what you are trying to achieve.\r\n\r\n1) Intercept the LINQ expression tree for rewriting. See #4048. \r\n2) Intercept the relinq QueryModel for rewriting: Register a custom IDatabase impl.\r\n3) Intercept SQL generation via sub-classing the provider's impl. E.g. SqlServerQuerySqlGenerator for SQL Server.\r\n\r\nIn this case, if you are just looking to modify the generated SQL string directly, then I would go with number 3."}}
{"actor":{"display_login":"anpete"}}