Permalink
Browse files

Added GetConnection method to dialect

  • Loading branch information...
1 parent 222eeda commit 0e5da7e839685d22b0194cbb82e5773350a97cda @jasondentler committed Feb 28, 2011
@@ -1,4 +1,5 @@
-using System;
+using System.Configuration;
+using System.Data;
using FluentDML.Mapping;
namespace FluentDML.Dialect
@@ -12,6 +13,17 @@ protected BaseDialect(Map map)
_map = map;
}
+ public virtual IDbConnection GetConnection(string connectionStringName)
+ {
+ var connStr = ConfigurationManager.ConnectionStrings[connectionStringName]
+ .ConnectionString;
+ var conn = CreateConnection();
+ conn.ConnectionString = connStr;
+ return conn;
+ }
+
+ protected abstract IDbConnection CreateConnection();
+
public IInsert<T> Insert<T>()
{
return CreateSqlInsert<T>(_map.GetClassMap<T>());
@@ -1,7 +1,11 @@
-namespace FluentDML.Dialect
+using System.Data;
+
+namespace FluentDML.Dialect
{
public interface IDialect
{
+
+ IDbConnection GetConnection(string connectionStringName);
IInsert<T> Insert<T>();
IDelete<T> Delete<T>();
IUpdate<T> Update<T>();
@@ -26,6 +26,12 @@ public MsSqlDialect(Map map)
{
}
+
+ protected override IDbConnection CreateConnection()
+ {
+ return new SqlConnection();
+ }
+
protected override IUpdate<T> CreateSqlUpdate<T>(ClassMap map)
{
return new MsSqlUpdate<T>(_commandConstructor, map);
@@ -1,4 +1,5 @@
-using System.Data;
+using System;
+using System.Data;
using System.Data.Common;
using FluentDML.Mapping;
@@ -18,6 +19,11 @@ protected IDbCommand CreateCommand()
return _provider.CreateCommand();
}
+ protected override IDbConnection CreateConnection()
+ {
+ return _provider.CreateConnection();
+ }
+
protected override IUpdate<T> CreateSqlUpdate<T>(ClassMap map)
{
return new SQLiteUpdate<T>(CreateCommand, map);
@@ -36,6 +36,7 @@
<HintPath>..\..\lib\AutoMapper\AutoMapper.dll</HintPath>
</Reference>
<Reference Include="System" />
+ <Reference Include="System.configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
@@ -85,6 +86,10 @@
<Compile Include="Mapping\IMapMaker.cs" />
<Compile Include="Mapping\Map.cs" />
<Compile Include="Mapping\MapMaker.cs" />
+ <Compile Include="ReadModel\Denormalizer.cs" />
+ <Compile Include="ReadModel\DialectExtensions.cs" />
+ <Compile Include="ReadModel\DoNothingMappingExpression.cs" />
+ <Compile Include="ReadModel\IDenormalizer.cs" />
<Compile Include="SyntaxExample.cs" />
<Compile Include="IDelete.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

0 comments on commit 0e5da7e

Please sign in to comment.