{"action":"opened","issue":{"url":"https://api.github.com/repos/linq2db/linq2db/issues/1486","repository_url":"https://api.github.com/repos/linq2db/linq2db","labels_url":"https://api.github.com/repos/linq2db/linq2db/issues/1486/labels{/name}","comments_url":"https://api.github.com/repos/linq2db/linq2db/issues/1486/comments","events_url":"https://api.github.com/repos/linq2db/linq2db/issues/1486/events","html_url":"https://github.com/linq2db/linq2db/issues/1486","id":393943383,"node_id":"MDU6SXNzdWUzOTM5NDMzODM=","number":1486,"title":"Providing a IDbConnection when using AllowMultipleQuery results in an exception","user":{"login":"Mitch528","id":932976,"node_id":"MDQ6VXNlcjkzMjk3Ng==","avatar_url":"https://avatars2.githubusercontent.com/u/932976?v=4","gravatar_id":"","url":"https://api.github.com/users/Mitch528","html_url":"https://github.com/Mitch528","followers_url":"https://api.github.com/users/Mitch528/followers","following_url":"https://api.github.com/users/Mitch528/following{/other_user}","gists_url":"https://api.github.com/users/Mitch528/gists{/gist_id}","starred_url":"https://api.github.com/users/Mitch528/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mitch528/subscriptions","organizations_url":"https://api.github.com/users/Mitch528/orgs","repos_url":"https://api.github.com/users/Mitch528/repos","events_url":"https://api.github.com/users/Mitch528/events{/privacy}","received_events_url":"https://api.github.com/users/Mitch528/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-25T01:17:19Z","updated_at":"2018-12-25T01:17:19Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Example:\r\n\r\n```csharp\r\npublic class IssueDataConnection : DataConnection\r\n{\r\n\tpublic IssueTestDataConnection(string configuration) : base(GetDataProvider(configuration, true),\r\n\t\tGetConnection(configuration), true)\r\n\t{\r\n\t}\r\n\r\n\tprivate static IDataProvider GetDataProvider(string configuration, bool avoidSpecific)\r\n\t{\r\n\t\tLinqToDB.Common.Configuration.Linq.AllowMultipleQuery = true;\r\n\r\n\t\tif (avoidSpecific)\r\n\t\t{\r\n\t\t\tLinqToDB.Common.Configuration.AvoidSpecificDataProviderAPI = true;\r\n\t\t}\r\n\r\n\t\treturn GetDataProvider(configuration);\r\n\t}\r\n\r\n\tprivate static IDbConnection GetConnection(string configuration)\r\n\t{\r\n\t\tstring connStr = GetConnectionString(configuration);\r\n\r\n\t\treturn GetDataProvider(configuration).CreateConnection(connStr);\r\n\t}\r\n}\r\n```\r\nThe following will throw an exception since LinqToDb tries to create another connection with a null connection string.\r\n\r\n```csharp\r\nusing (var db = new IssueDataConnection(config))\r\n{\r\n\tdb.GetTable<Child>().LoadWith(p => p.Parent.Children).First();\r\n}\r\n```\r\n\r\nException:\r\n\r\n```\r\nSystem.ArgumentNullException : Value cannot be null.\r\nParameter name: key\r\n   at System.Collections.Concurrent.ConcurrentDictionary`2.ThrowKeyNullException()\r\n   at System.Collections.Concurrent.ConcurrentDictionary`2.TryGetValue(TKey key, TValue& value)\r\n   at MySqlConnector.Core.ConnectionPool.GetPool(String connectionString) in C:\\projects\\mysqlconnector\\src\\MySqlConnector\\Core\\ConnectionPool.cs:line 368\r\n   at MySql.Data.MySqlClient.MySqlConnection.<CreateSessionAsync>d__96.MoveNext() in C:\\projects\\mysqlconnector\\src\\MySqlConnector\\MySql.Data.MySqlClient\\MySqlConnection.cs:line 487\r\n--- End of stack trace from previous location where exception was thrown ---\r\n```\r\n\r\nPossible solutions:\r\n- Set `ConnectionString = connection.ConnectionString` in the constructor overload.\r\n- Provide a factory method that can be used to retrieve an IDbConnection instead of passing one in via the constructor. This is probably the ideal solution, but would be a breaking change.\r\n\r\n\r\n### Environment details\r\nlinq2db version: 2.7.0\r\nDatabase Server: MySql\r\nDatabase Provider: MySqlConnector\r\nOperating system: Windows 10\r\nFramework version: .NET Core 2.0"}}
{"actor":{"display_login":"Mitch528"}}