{"action":"created","issue":{"url":"https://api.github.com/repos/StackExchange/dapper-dot-net/issues/491","repository_url":"https://api.github.com/repos/StackExchange/dapper-dot-net","labels_url":"https://api.github.com/repos/StackExchange/dapper-dot-net/issues/491/labels{/name}","comments_url":"https://api.github.com/repos/StackExchange/dapper-dot-net/issues/491/comments","events_url":"https://api.github.com/repos/StackExchange/dapper-dot-net/issues/491/events","html_url":"https://github.com/StackExchange/dapper-dot-net/issues/491","id":144819118,"number":491,"title":"Multiple Results in Oracle","user":{"login":"imman731","id":14903816,"avatar_url":"https://avatars.githubusercontent.com/u/14903816?v=3","gravatar_id":"","url":"https://api.github.com/users/imman731","html_url":"https://github.com/imman731","followers_url":"https://api.github.com/users/imman731/followers","following_url":"https://api.github.com/users/imman731/following{/other_user}","gists_url":"https://api.github.com/users/imman731/gists{/gist_id}","starred_url":"https://api.github.com/users/imman731/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imman731/subscriptions","organizations_url":"https://api.github.com/users/imman731/orgs","repos_url":"https://api.github.com/users/imman731/repos","events_url":"https://api.github.com/users/imman731/events{/privacy}","received_events_url":"https://api.github.com/users/imman731/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-03-31T07:59:35Z","updated_at":"2016-07-12T04:13:46Z","closed_at":null,"body":"Is dapper support Multiple Results in Oracle (via C# .net)?\r\nI have an Error ORA:00933.\r\n\r\nsimple code as below, but it's still got error.\r\nvar sqlStr = @\"\r\n                             select sysdate from dual a\r\n                             select sysdate from dual b\";\r\n                IDbConnection cnn = DBCnn;\r\n                using (var multi = cnn.QueryMultiple(sqlStr, null))\r\n                {\r\n                     ....\r\n                }\r\n"},"comment":{"url":"https://api.github.com/repos/StackExchange/dapper-dot-net/issues/comments/231932930","html_url":"https://github.com/StackExchange/dapper-dot-net/issues/491#issuecomment-231932930","issue_url":"https://api.github.com/repos/StackExchange/dapper-dot-net/issues/491","id":231932930,"user":{"login":"ducminh","id":12380929,"avatar_url":"https://avatars.githubusercontent.com/u/12380929?v=3","gravatar_id":"","url":"https://api.github.com/users/ducminh","html_url":"https://github.com/ducminh","followers_url":"https://api.github.com/users/ducminh/followers","following_url":"https://api.github.com/users/ducminh/following{/other_user}","gists_url":"https://api.github.com/users/ducminh/gists{/gist_id}","starred_url":"https://api.github.com/users/ducminh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ducminh/subscriptions","organizations_url":"https://api.github.com/users/ducminh/orgs","repos_url":"https://api.github.com/users/ducminh/repos","events_url":"https://api.github.com/users/ducminh/events{/privacy}","received_events_url":"https://api.github.com/users/ducminh/received_events","type":"User","site_admin":false},"created_at":"2016-07-12T04:13:46Z","updated_at":"2016-07-12T04:13:46Z","body":"Use solution from this page\r\nhttp://www.scriptscoop.site/t/1315f32d24ed/using-dapper-querymultiple-in-oracle.html\r\n\r\nusing Dapper;\r\nusing Oracle.ManagedDataAccess.Client;\r\nusing System.Data;\r\n\r\nint selectedId = 1;\r\nvar sql = \"BEGIN OPEN :rslt1 FOR SELECT * FROM customers WHERE customerid = :id; \" +\r\n                \"OPEN :rslt2 FOR SELECT * FROM orders WHERE customerid = :id; \" +\r\n                \"OPEN :rslt3 FOR SELECT * FROM returns Where customerid = :id; \" +\r\n          \"END;\";\r\n\r\nOracleDynamicParameters dynParams = new OracleDynamicParameters();\r\ndynParams.Add(\":rslt1\", OracleDbType.RefCursor, ParameterDirection.Output);\r\ndynParams.Add(\":rslt2\", OracleDbType.RefCursor, ParameterDirection.Output);\r\ndynParams.Add(\":rslt3\", OracleDbType.RefCursor, ParameterDirection.Output);\r\ndynParams.Add(\":id\", OracleDbType.Int32, ParameterDirection.Input, selectedId);\r\n\r\nusing (IDbConnection dbConn = new OracleConnection(\"<conn string here>\"))\r\n{\r\n    dbConn.Open();\r\n    var multi = dbConn.QueryMultiple(sql, param: dynParams);\r\n\r\n    var customer = multi.Read<Customer>().Single();\r\n    var orders = multi.Read<Order>().ToList();\r\n    var returns = multi.Read<Return>().ToList();\r\n    ...\r\n    dbConn.Close();\r\n}\r\n\r\n------------------------------------\r\n\r\nusing Dapper;\r\nusing Oracle.ManagedDataAccess.Client;\r\nusing System.Data;\r\n\r\npublic class OracleDynamicParameters : SqlMapper.IDynamicParameters\r\n{\r\n    private readonly DynamicParameters dynamicParameters = new DynamicParameters();\r\n\r\n    private readonly List<OracleParameter> oracleParameters = new List<OracleParameter>();\r\n\r\n    public void Add(string name, OracleDbType oracleDbType, ParameterDirection direction, object value = null, int? size = null)\r\n    {\r\n        OracleParameter oracleParameter;\r\n        if (size.HasValue)\r\n        {\r\n            oracleParameter = new OracleParameter(name, oracleDbType, size.Value, value, direction);\r\n        }\r\n        else\r\n        {\r\n            oracleParameter = new OracleParameter(name, oracleDbType, value, direction);\r\n        }\r\n\r\n        oracleParameters.Add(oracleParameter);\r\n    }\r\n\r\n    public void Add(string name, OracleDbType oracleDbType, ParameterDirection direction)\r\n    {\r\n        var oracleParameter = new OracleParameter(name, oracleDbType, direction);\r\n        oracleParameters.Add(oracleParameter);\r\n    }\r\n\r\n    public void AddParameters(IDbCommand command, SqlMapper.Identity identity)\r\n    {\r\n        ((SqlMapper.IDynamicParameters)dynamicParameters).AddParameters(command, identity);\r\n\r\n        var oracleCommand = command as OracleCommand;\r\n\r\n        if (oracleCommand != null)\r\n        {\r\n            oracleCommand.Parameters.AddRange(oracleParameters.ToArray());\r\n        }\r\n    }\r\n}"}}
{"actor":{"display_login":"ducminh"}}