{"action":"created","issue":{"url":"https://api.github.com/repos/StackExchange/dapper-dot-net/issues/292","labels_url":"https://api.github.com/repos/StackExchange/dapper-dot-net/issues/292/labels{/name}","comments_url":"https://api.github.com/repos/StackExchange/dapper-dot-net/issues/292/comments","events_url":"https://api.github.com/repos/StackExchange/dapper-dot-net/issues/292/events","html_url":"https://github.com/StackExchange/dapper-dot-net/pull/292","id":84430326,"number":292,"title":"Query method with IDbCommand parameter added","user":{"login":"alexeyfadeev","id":11972666,"avatar_url":"https://avatars.githubusercontent.com/u/11972666?v=3","gravatar_id":"","url":"https://api.github.com/users/alexeyfadeev","html_url":"https://github.com/alexeyfadeev","followers_url":"https://api.github.com/users/alexeyfadeev/followers","following_url":"https://api.github.com/users/alexeyfadeev/following{/other_user}","gists_url":"https://api.github.com/users/alexeyfadeev/gists{/gist_id}","starred_url":"https://api.github.com/users/alexeyfadeev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexeyfadeev/subscriptions","organizations_url":"https://api.github.com/users/alexeyfadeev/orgs","repos_url":"https://api.github.com/users/alexeyfadeev/repos","events_url":"https://api.github.com/users/alexeyfadeev/events{/privacy}","received_events_url":"https://api.github.com/users/alexeyfadeev/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-06-03T08:21:55Z","updated_at":"2015-08-21T10:52:04Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/StackExchange/dapper-dot-net/pulls/292","html_url":"https://github.com/StackExchange/dapper-dot-net/pull/292","diff_url":"https://github.com/StackExchange/dapper-dot-net/pull/292.diff","patch_url":"https://github.com/StackExchange/dapper-dot-net/pull/292.patch"},"body":"Added Query<T> and QueryImpl<T> methods with IDbCommand argument. It can be usefull to upgrade legacy projects using DbCommand and manual mapping and start using Dapper instead.\r\n\r\nAlso with this method no need to rebind the DbParameter collection to DbCommand from DynamicParameter List every time.\r\n\r\nIn addition, it's possible to use Dapper and LINQ to SQL together. LINQ to SQL allows to convert LINQ query to DBCommand, then it should be passed to this new Dapper method.\r\n\r\nAdditional discussion on Issue #270."},"comment":{"url":"https://api.github.com/repos/StackExchange/dapper-dot-net/issues/comments/133372016","html_url":"https://github.com/StackExchange/dapper-dot-net/pull/292#issuecomment-133372016","issue_url":"https://api.github.com/repos/StackExchange/dapper-dot-net/issues/292","id":133372016,"user":{"login":"DamianReeves","id":957246,"avatar_url":"https://avatars.githubusercontent.com/u/957246?v=3","gravatar_id":"","url":"https://api.github.com/users/DamianReeves","html_url":"https://github.com/DamianReeves","followers_url":"https://api.github.com/users/DamianReeves/followers","following_url":"https://api.github.com/users/DamianReeves/following{/other_user}","gists_url":"https://api.github.com/users/DamianReeves/gists{/gist_id}","starred_url":"https://api.github.com/users/DamianReeves/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DamianReeves/subscriptions","organizations_url":"https://api.github.com/users/DamianReeves/orgs","repos_url":"https://api.github.com/users/DamianReeves/repos","events_url":"https://api.github.com/users/DamianReeves/events{/privacy}","received_events_url":"https://api.github.com/users/DamianReeves/received_events","type":"User","site_admin":false},"created_at":"2015-08-21T10:52:04Z","updated_at":"2015-08-21T10:52:04Z","body":"@mgravell I really feel having an extension method off of IDataReader is needed and would be helpful. I have current situations  where some other library I don't own gives me a IDataReader and it needs to be Deserialized/Materialized/Populated (whatever you want to call it) to an object. \r\nRight now Dapper has the code to do this, but to get at it you need to access the private `GetDeserializer` method.\r\nThe [Insight.Database](https://github.com/jonwagner/Insight.Database) project, which was originally based on Dapper, provides access through IDataReader and it is very helpful.\r\n\r\nI end up taking in SqlMapper as a code file (which I wish we still directly supported through NuGet) and add the following:\r\n\r\n    partial class SqlMapper\r\n    {\r\n        public static IEnumerable<T> ToSequence<T>(this IDataReader reader)\r\n        {\r\n            if (reader == null)\r\n            {\r\n                throw new ArgumentNullException(\"reader\");\r\n            }\r\n            var deserializer = GetDeserializer(typeof(T), reader, 0, -1, false);\r\n            while (reader.Read())\r\n            {\r\n                yield return (T)deserializer(reader);\r\n            }\r\n        }\r\n\r\n        public static IList<T> ToList<T>(this IDataReader reader)\r\n        {\r\n            return reader.ToSequence<T>().ToList();\r\n        }\r\n    }"}}