File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Concurrent ;
33using System . ComponentModel . Composition . Hosting ;
4+ using System . Data . OleDb ;
45using System . Reflection ;
56using System . IO ;
67
@@ -22,6 +23,13 @@ public static IConnectionProvider GetProviderByFilename(string filename)
2223
2324 private static IConnectionProvider LoadProviderByConnectionString ( string connectionString )
2425 {
26+ var connectionStringBuilder = new OleDbConnectionStringBuilder ( connectionString ) ;
27+
28+ if ( connectionStringBuilder . DataSource . EndsWith ( "sdf" , StringComparison . CurrentCultureIgnoreCase ) && File . Exists ( connectionStringBuilder . DataSource ) )
29+ {
30+ return GetProviderByFilename ( connectionStringBuilder . DataSource ) ;
31+ }
32+
2533 var provider = ComposeProvider ( "sql" ) ;
2634
2735 provider . SetConnectionString ( connectionString ) ;
Original file line number Diff line number Diff line change @@ -19,12 +19,19 @@ public class FindTests
1919 "TestDatabase.sdf" ) ;
2020
2121 [ Test ]
22- public void TestMethod1 ( )
22+ public void TestProviderWithFileName ( )
2323 {
2424 var provider = ProviderHelper . GetProviderByFilename ( DatabasePath ) ;
2525 Assert . IsInstanceOf ( typeof ( SqlCe40ConnectionProvider ) , provider ) ;
2626 }
2727
28+ [ Test ]
29+ public void TestProviderWithConnectionString ( )
30+ {
31+ var provider = ProviderHelper . GetProviderByConnectionString ( string . Format ( "data source={0}" , DatabasePath ) ) ;
32+ Assert . IsInstanceOf ( typeof ( SqlCe40ConnectionProvider ) , provider ) ;
33+ }
34+
2835 [ Test ]
2936 public void TestFindById ( )
3037 {
You can’t perform that action at this time.
0 commit comments