Follow up from mono-devel-l...@. This patch munge the parameters from
the connection string to make sure Npgsql does not choke on unknow
parameters.

federico

-- 
Federico Di Gregorio                         http://people.initd.org/fog
Debian GNU/Linux Developer                                [email protected]
INIT.D Developer                                           [email protected]
                   Datemi uno spigolo. Che lo arrotondo tutto. -- <dani>
Index: src/DbLinq.Firebird/DbLinq.Firebird.csproj
===================================================================
Index: src/DbLinq.SqlServer/DbLinq.SqlServer.csproj
===================================================================
Index: src/DbLinq.Ingres/DbLinq.Ingres.csproj
===================================================================
Index: src/DbMetal/DbMetal.csproj
===================================================================
Index: src/DbLinq.Sqlite/DbLinq.Sqlite.csproj
===================================================================
Index: src/DbLinq/DbLinq.csproj
===================================================================
Index: src/DbLinq/Data/Linq/DataContext.cs
===================================================================
--- src/DbLinq/Data/Linq/DataContext.cs	(revisione 1141)
+++ src/DbLinq/Data/Linq/DataContext.cs	(copia locale)
@@ -169,7 +169,7 @@
                 throw new NotImplementedException("Server name not supported.");
 
             // Assume it's a connection string...
-            IVendor ivendor = GetVendor(fileOrServerOrConnection);
+            IVendor ivendor = GetVendor(ref fileOrServerOrConnection);
 
             IDbConnection dbConnection = ivendor.CreateDbConnection(fileOrServerOrConnection);
             Init(new DatabaseContext(dbConnection), mapping, ivendor);
@@ -188,21 +188,21 @@
         [DbLinqToDo]
         public DataContext(string connectionString)
         {
-            IVendor ivendor = GetVendor(connectionString);
+            IVendor ivendor = GetVendor(ref connectionString);
 
             IDbConnection dbConnection = ivendor.CreateDbConnection(connectionString);
             Init(new DatabaseContext(dbConnection), null, ivendor);
 
         }
 
-        private IVendor GetVendor(string connectionString)
+        private IVendor GetVendor(ref string connectionString)
         {
             if (connectionString == null)
                 throw new ArgumentNullException("connectionString");
 
             Assembly assy;
             string vendorClassToLoad;
-            GetVendorInfo(connectionString, out assy, out vendorClassToLoad);
+            GetVendorInfo(ref connectionString, out assy, out vendorClassToLoad);
 
             var types =
                 from type in assy.GetTypes()
@@ -223,10 +223,10 @@
             return (IVendor) Activator.CreateInstance(types.First());
         }
 
-        private void GetVendorInfo(string connectionString, out Assembly assembly, out string typeName)
+        private void GetVendorInfo(ref string connectionString, out Assembly assembly, out string typeName)
         {
             System.Text.RegularExpressions.Regex reProvider
-                = new System.Text.RegularExpressions.Regex(@"DbLinqProvider=([\w\.]+)");
+                = new System.Text.RegularExpressions.Regex(@"DbLinqProvider=([\w\.]+);?");
 
             string assemblyFile = null;
             string vendor;
@@ -283,13 +283,15 @@
             if (databaseContext.Connection.ConnectionString == null)
                 throw new NullReferenceException();
 
+			string connectionString = databaseContext.Connection.ConnectionString;
             _VendorProvider = ObjectFactory.Get<IVendorProvider>();
             Vendor = vendor ?? 
                 (databaseContext.Connection.ConnectionString != null
-                    ? GetVendor(databaseContext.Connection.ConnectionString)
+                    ? GetVendor(ref connectionString)
                     : null) ??
                 _VendorProvider.FindVendorByProviderType(typeof(SqlClient.Sql2005Provider));
-
+            databaseContext.Connection.ConnectionString = connectionString;
+			
             DatabaseContext = databaseContext;
 
             MemberModificationHandler = ObjectFactory.Create<IMemberModificationHandler>(); // not a singleton: object is stateful
@@ -429,7 +431,6 @@
                             break;
                         default:
                             throw new ArgumentOutOfRangeException();
-                            break;
                     }
                 }
                 // TODO: handle conflicts (which can only occur when concurrency mode is implemented)
Index: src/DbLinq/Vendor/Implementation/Vendor.cs
===================================================================
--- src/DbLinq/Vendor/Implementation/Vendor.cs	(revisione 1141)
+++ src/DbLinq/Vendor/Implementation/Vendor.cs	(copia locale)
@@ -31,13 +31,14 @@
 using System.Linq;
 
 #if MONO_STRICT
+using DataContext = System.Data.Linq.DataContext;
+using Data = System.Data;
 using System.Data.Linq;
 #else
+using DataContext = DbLinq.Data.Linq.DataContext;
+using Data = DbLinq.Data;
 using DbLinq.Data.Linq;
 #endif
-
-using Data = DbLinq.Data;
-
 using IExecuteResult = System.Data.Linq.IExecuteResult;
 
 namespace DbLinq.Vendor.Implementation
@@ -46,10 +47,12 @@
     /// some IVendor functionality is the same for many vendors,
     /// implemented here as virtual functions.
     /// </summary>
-#if !MONO_STRICT
+#if MONO_STRICT
+    internal
+#else
     public
 #endif
-    abstract partial class Vendor : IVendor
+ abstract partial class Vendor : IVendor
     {
         /// <summary>
         /// Pings requested DB, true is result is OK.
@@ -163,7 +166,7 @@
         /// </summary>
         public IDbConnection CreateDbConnection(string connectionString)
         {
-            var reConnectionType = new System.Text.RegularExpressions.Regex(@"DbLinqConnectionType=([^;]*)");
+            var reConnectionType = new System.Text.RegularExpressions.Regex(@"DbLinqConnectionType=([^;]*);?");
             string connTypeVal = null;
             if (!reConnectionType.IsMatch(connectionString))
             {
@@ -176,7 +179,7 @@
                 connectionString    = reConnectionType.Replace(connectionString, "");
             }
 
-            var    connType     = Type.GetType(connTypeVal);
+            var connType = Type.GetType(connTypeVal);
             if (connType == null)
                 throw new ArgumentException(string.Format(
                         "Could not load the specified DbLinqConnectionType `{0}'.",
Index: src/DbLinq/System.Data.Linq.csproj
===================================================================
Index: src/DbLinq.PostgreSql/DbLinq.PostgreSql.csproj
===================================================================
Index: src/DbLinq.Oracle/DbLinq.Oracle.csproj
===================================================================
Index: src/DbLinq.MySql/DbLinq.MySql.csproj
===================================================================

Attachment: signature.asc
Description: Questa รจ una parte del messaggio firmata digitalmente

Reply via email to