Git Product home page Git Product logo

Comments (6)

pezipink avatar pezipink commented on May 11, 2024

Ok - I thought I had some connection managing code in the design-time stuff, but perhaps not. It's odd this has not been encountered up until now though. I will have a look at this later today, thanks

from sqlprovider.

Frassle avatar Frassle commented on May 11, 2024

Thanks. If you need/want any help I'm happy to build and test any patches.

from sqlprovider.

Frassle avatar Frassle commented on May 11, 2024

As a work around I'm caching IDbConnections in createTypes. It should probably be keyed on provider type as well as connection string but the following works for me:

diff --git a/src/SQLProvider/SqlDesignTime.fs b/src/SQLProvider/SqlDesignTime.fs
index 64b41b0..840b502 100644
--- a/src/SQLProvider/SqlDesignTime.fs
+++ b/src/SQLProvider/SqlDesignTime.fs
@@ -29,11 +29,11 @@ type SqlTypeProvider(config: TypeProviderConfig) as this =
     let sqlRuntimeInfo = SqlRuntimeInfo(config)
     let ns = "FSharp.Data.Sql";   
     let asm = Assembly.GetExecutingAssembly()
+    let connections = System.Collections.Concurrent.ConcurrentDictionary<string,IDbConnection>()

     let createTypes(conString,dbVendor,resolutionPath,individualsAmount,useOptionTypes,owner, rootTypeName) =       
         let prov = Common.Utilities.createSqlProvider dbVendor resolutionPath owner
-        let con = prov.CreateConnection conString
-        con.Open()
+        let con = connections.GetOrAdd(conString, (fun cs -> let con = prov.CreateConnection cs in con.Open(); con))
         prov.CreateTypeMappings con

         let tables = lazy prov.GetTables con

from sqlprovider.

pezipink avatar pezipink commented on May 11, 2024

This should hopefully be fixed now within here fba62ce

I changed the connection life cycles to be much more explicit in general - plus there was a key connection.Close() missing from the design-time code which is likely what was causing your issue. Please give it a go and let me know you get on, I made massive changes here to fix other stuff as well so all testing feedback is much appreciated, thanks!

from sqlprovider.

Frassle avatar Frassle commented on May 11, 2024

I ran into an issue when using count that the connection wasn't open. My commit Frassle@08134e1 seems to have fixed it.

The issue with too many connections does seem to have been fixed though :)

from sqlprovider.

pezipink avatar pezipink commented on May 11, 2024

Ahh, thanks, good shout. I missed that one. I have remade that change my side as it's just the single line. Let me know if you run into any other issues.

from sqlprovider.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.