Commit b30bcab7 authored by Sam Saffron's avatar Sam Saffron

remove orm lite .. broken

add support for multi dbs, keys on connection string
parent 9492f3f6
...@@ -138,9 +138,15 @@ public void Run(int iterations) ...@@ -138,9 +138,15 @@ public void Run(int iterations)
tests.Add(id => db1.SetCommand("select * from Posts where Id = @id", db1.Parameter("id", id)).ExecuteList<Post>(), "BLToolkit"); tests.Add(id => db1.SetCommand("select * from Posts where Id = @id", db1.Parameter("id", id)).ExecuteList<Post>(), "BLToolkit");
//ServiceStack.OrmLite Provider: //ServiceStack.OrmLite Provider:
OrmLiteConfig.DialectProvider = SqlServerOrmLiteDialectProvider.Instance; //Using SQL Server /*
IDbCommand ormLiteCmd = Program.GetOpenConnection().CreateCommand(); * Unhandled Exception: System.FormatException: Input string was not in a correct f
tests.Add(id => ormLiteCmd.Select<Post>("select * from Posts where Id = {0}", id), "ServiceStack.OrmLite SQL Query"); ormat.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffe
r& number, NumberFormatInfo info, Boolean parseDecimal)
*/
// OrmLiteConfig.DialectProvider = SqlServerOrmLiteDialectProvider.Instance; //Using SQL Server
// IDbCommand ormLiteCmd = Program.GetOpenConnection().CreateCommand();
// tests.Add(id => ormLiteCmd.Select<Post>("select * from Posts where Id = {0}", id), "ServiceStack.OrmLite SQL Query");
// HAND CODED // HAND CODED
......
...@@ -99,16 +99,18 @@ public static ParamInfo Create(string name, DbType type, object val) ...@@ -99,16 +99,18 @@ public static ParamInfo Create(string name, DbType type, object val)
private class Identity : IEquatable<Identity> private class Identity : IEquatable<Identity>
{ {
public String ConnectionString { get {return connectionString;} }
public Type Type { get { return type; } } public Type Type { get { return type; } }
public string Sql { get { return sql; } } public string Sql { get { return sql; } }
internal Identity(string sql, Type type) internal Identity(string sql, IDbConnection cnn, Type type)
{ {
this.sql = sql; this.sql = sql;
this.connectionString = cnn.ConnectionString;
this.type = type; this.type = type;
hashCode = 17; // we *know* we are using this in a dictionary, so pre-compute this hashCode = 17; // we *know* we are using this in a dictionary, so pre-compute this
hashCode = hashCode * 23 + (sql == null ? 0 : sql.GetHashCode()); hashCode = hashCode * 23 + (sql == null ? 0 : sql.GetHashCode());
hashCode = hashCode * 23 + (type == null ? 0 : type.GetHashCode()); hashCode = hashCode * 23 + (type == null ? 0 : type.GetHashCode());
hashCode = hashCode * 23 + (connectionString == null ? 0 : connectionString.GetHashCode());
} }
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
...@@ -117,6 +119,7 @@ public override bool Equals(object obj) ...@@ -117,6 +119,7 @@ public override bool Equals(object obj)
private readonly string sql; private readonly string sql;
private readonly int hashCode; private readonly int hashCode;
private readonly Type type; private readonly Type type;
private readonly string connectionString;
public override int GetHashCode() public override int GetHashCode()
{ {
return hashCode; return hashCode;
...@@ -124,7 +127,7 @@ public override int GetHashCode() ...@@ -124,7 +127,7 @@ public override int GetHashCode()
public bool Equals(Identity other) public bool Equals(Identity other)
{ {
return other != null && this.type == other.type return other != null && this.type == other.type
&& sql == other.sql; && sql == other.sql && connectionString == other.connectionString;
} }
} }
...@@ -144,7 +147,7 @@ static class DynamicStub ...@@ -144,7 +147,7 @@ static class DynamicStub
public static List<dynamic> ExecuteMapperQuery (this IDbConnection cnn, string sql, object param = null, SqlTransaction transaction = null) public static List<dynamic> ExecuteMapperQuery (this IDbConnection cnn, string sql, object param = null, SqlTransaction transaction = null)
{ {
var identity = new Identity(sql, DynamicStub.Type); var identity = new Identity(sql,cnn, DynamicStub.Type);
var list = new List<dynamic>(); var list = new List<dynamic>();
using (var reader = GetReader(cnn, transaction, sql, GetParamInfo(param))) using (var reader = GetReader(cnn, transaction, sql, GetParamInfo(param)))
...@@ -161,9 +164,10 @@ public static List<dynamic> ExecuteMapperQuery (this IDbConnection cnn, string s ...@@ -161,9 +164,10 @@ public static List<dynamic> ExecuteMapperQuery (this IDbConnection cnn, string s
public static List<T> ExecuteMapperQuery<T>(this IDbConnection cnn, string sql, object param = null, SqlTransaction transaction = null) public static List<T> ExecuteMapperQuery<T>(this IDbConnection cnn, string sql, object param = null, SqlTransaction transaction = null)
{ {
var identity = new Identity(sql, typeof(T)); var identity = new Identity(sql, cnn, typeof(T));
var rval = new List<T>(); var rval = new List<T>();
using (var reader = GetReader(cnn, transaction, sql, GetParamInfo(param))) using (var reader = GetReader(cnn, transaction, sql, GetParamInfo(param)))
{ {
Func<IDataReader, T> deserializer = GetDeserializer<T>(identity, reader); Func<IDataReader, T> deserializer = GetDeserializer<T>(identity, reader);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment