diff --git a/Dapper NET40/SqlMapper.cs b/Dapper NET40/SqlMapper.cs
index 3ff847c004cd0b7225e5788395f41444cb1826dc..a68fd1658fb9aead04a005bf25a2b4ac1a0396f5 100644
--- a/Dapper NET40/SqlMapper.cs
+++ b/Dapper NET40/SqlMapper.cs
@@ -34,7 +34,6 @@
using System.Globalization;
using System.Linq.Expressions;
using System.Data.Common;
-using System.Data.SqlClient;
namespace Dapper
{
@@ -90,13 +89,11 @@ internal static CommandDefinition ForCallback(object parameters)
internal void OnCompleted()
{
- var parametersCallbacks = parameters as SqlMapper.IParameterCallbacks;
- if (parametersCallbacks != null)
+ if (parameters is SqlMapper.IParameterCallbacks)
{
- parametersCallbacks.OnCompleted();
+ ((SqlMapper.IParameterCallbacks)parameters).OnCompleted();
}
}
-
///
/// The command (sql or a stored-procedure name) to execute
///
@@ -379,10 +376,9 @@ object ITypeHandler.Parse(Type destinationType, object value)
void ITypeHandler.SetValue(IDbDataParameter parameter, object value)
{
parameter.Value = SanitizeParameterValue(value);
- var sqlParameter = parameter as SqlParameter;
- if (sqlParameter != null)
+ if (parameter is System.Data.SqlClient.SqlParameter)
{
- sqlParameter.UdtTypeName = udtTypeName;
+ ((System.Data.SqlClient.SqlParameter)parameter).UdtTypeName = udtTypeName;
}
}
}
@@ -2806,7 +2802,7 @@ public static void PackListParameters(IDbCommand command, string namePrefix, obj
listParam.Size = -1;
}
}
- if (isDbString && item is DbString)
+ if (isDbString && item as DbString != null)
{
var str = item as DbString;
str.AddParameter(command, listParam.ParameterName);
@@ -3040,7 +3036,14 @@ internal static IList GetLiteralTokens(string sql)
var matches = literalTokens.Matches(sql);
var found = new HashSet(StringComparer.Ordinal);
List list = new List(matches.Count);
- list.AddRange(from Match match in matches let token = match.Value where found.Add(match.Value) select new LiteralToken(token, match.Groups[1].Value));
+ foreach(Match match in matches)
+ {
+ string token = match.Value;
+ if(found.Add(match.Value))
+ {
+ list.Add(new LiteralToken(token, match.Groups[1].Value));
+ }
+ }
return list.Count == 0 ? LiteralToken.None : list;
}
@@ -3092,7 +3095,15 @@ internal static IList GetLiteralTokens(string sql)
if (ctors.Length == 1 && propsArr.Length == (ctorParams = ctors[0].GetParameters()).Length)
{
// check if reflection was kind enough to put everything in the right order for us
- bool ok = !propsArr.Where((t, i) => !string.Equals(t.Name, ctorParams[i].Name, StringComparison.OrdinalIgnoreCase)).Any();
+ bool ok = true;
+ for (int i = 0; i < propsArr.Length; i++)
+ {
+ if (!string.Equals(propsArr[i].Name, ctorParams[i].Name, StringComparison.OrdinalIgnoreCase))
+ {
+ ok = false;
+ break;
+ }
+ }
if(ok)
{
// pre-sorted; the reflection gods have smiled upon us
diff --git a/Dapper.Contrib.Tests NET45/Properties/AssemblyInfo.cs b/Dapper.Contrib.Tests NET45/Properties/AssemblyInfo.cs
index 5981912361c81d568be6c4f22cba3700d4d5acb5..34276d4dcee776a946b7afeefb048267ca5731e0 100644
--- a/Dapper.Contrib.Tests NET45/Properties/AssemblyInfo.cs
+++ b/Dapper.Contrib.Tests NET45/Properties/AssemblyInfo.cs
@@ -1,4 +1,5 @@
using System.Reflection;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
diff --git a/Dapper.Contrib.Tests/Properties/AssemblyInfo.cs b/Dapper.Contrib.Tests/Properties/AssemblyInfo.cs
index 87e8c39b2c4d9e985181461b93d41f57fdd73a60..d789c72c991a790638b3b5a3b621906462a35b1c 100644
--- a/Dapper.Contrib.Tests/Properties/AssemblyInfo.cs
+++ b/Dapper.Contrib.Tests/Properties/AssemblyInfo.cs
@@ -1,4 +1,5 @@
using System.Reflection;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
diff --git a/Dapper.Rainbow NET45/DatabaseAsync.cs b/Dapper.Rainbow NET45/DatabaseAsync.cs
index aca34e8bfcae5c86d5d0b465e96777a87b401bb8..266ca90e4018ab768896c6fc7392e2d784394628 100644
--- a/Dapper.Rainbow NET45/DatabaseAsync.cs
+++ b/Dapper.Rainbow NET45/DatabaseAsync.cs
@@ -1,7 +1,10 @@
using System;
+using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data;
+using System.Data.Common;
using System.Linq;
+using System.Reflection;
using System.Text;
using System.Threading.Tasks;
@@ -23,8 +26,8 @@ public partial class Table
paramNames.Remove("Id");
string cols = string.Join(",", paramNames);
- string colsParams = string.Join(",", paramNames.Select(p => "@" + p));
- var sql = "set nocount on insert " + TableName + " (" + cols + ") values (" + colsParams + ") select cast(scope_identity() as int)";
+ string cols_params = string.Join(",", paramNames.Select(p => "@" + p));
+ var sql = "set nocount on insert " + TableName + " (" + cols + ") values (" + cols_params + ") select cast(scope_identity() as int)";
return (await database.QueryAsync(sql, o).ConfigureAwait(false)).Single();
}
diff --git a/Dapper.Rainbow/Database.cs b/Dapper.Rainbow/Database.cs
index c84849558a5e309bf5c52ee517321d8b3bba1b1b..c35a6b4e30ac4e801a08aaa5b112c43a95cb9372 100644
--- a/Dapper.Rainbow/Database.cs
+++ b/Dapper.Rainbow/Database.cs
@@ -131,7 +131,7 @@ internal static List GetParamNames(object o)
{
var attribs = prop.GetCustomAttributes(typeof(IgnorePropertyAttribute), true);
var attr = attribs.FirstOrDefault() as IgnorePropertyAttribute;
- if (attr==null || !attr.Value)
+ if (attr==null || (!attr.Value))
{
paramNames.Add(prop.Name);
}
diff --git a/Dapper.Rainbow/Properties/AssemblyInfo.cs b/Dapper.Rainbow/Properties/AssemblyInfo.cs
index 4e2087b08c79e51b1d711f6467455c6e80bba960..8ea5cd0f69c7220afb28f59af65635876f4ce783 100644
--- a/Dapper.Rainbow/Properties/AssemblyInfo.cs
+++ b/Dapper.Rainbow/Properties/AssemblyInfo.cs
@@ -1,4 +1,5 @@
using System.Reflection;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
diff --git a/Dapper.Rainbow/Snapshotter.cs b/Dapper.Rainbow/Snapshotter.cs
index 442e128fc67b27d7c4e0d2230c3f1f74daf5a806..c8dbe2bc39da0c9a2ae275e4e138ca2971c57db5 100644
--- a/Dapper.Rainbow/Snapshotter.cs
+++ b/Dapper.Rainbow/Snapshotter.cs
@@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Web;
using System.Reflection;
using System.Reflection.Emit;
diff --git a/Dapper.SqlBuilder NET45/Properties/AssemblyInfo.cs b/Dapper.SqlBuilder NET45/Properties/AssemblyInfo.cs
index b63acbdb0b2a47f79bdf04d886898801f4381cdb..092e88393616a3ec1b813be6e4a7996ea469a3c4 100644
--- a/Dapper.SqlBuilder NET45/Properties/AssemblyInfo.cs
+++ b/Dapper.SqlBuilder NET45/Properties/AssemblyInfo.cs
@@ -1,4 +1,5 @@
using System.Reflection;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
diff --git a/Dapper.SqlBuilder/Properties/AssemblyInfo.cs b/Dapper.SqlBuilder/Properties/AssemblyInfo.cs
index c71f2d47f192dbca07e7838bbe104f9d43970b8e..c28c4b0db2792ea195a82f890190592c709de122 100644
--- a/Dapper.SqlBuilder/Properties/AssemblyInfo.cs
+++ b/Dapper.SqlBuilder/Properties/AssemblyInfo.cs
@@ -1,4 +1,5 @@
using System.Reflection;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
diff --git a/Dapper.SqlBuilder/SqlBuilder.cs b/Dapper.SqlBuilder/SqlBuilder.cs
index 8b9eaf5dedaf343b7e66ce917bfb595b429133e8..f3c256b40a90154b18ff636f744fb4fba9f92925 100644
--- a/Dapper.SqlBuilder/SqlBuilder.cs
+++ b/Dapper.SqlBuilder/SqlBuilder.cs
@@ -1,5 +1,7 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Linq;
+using System.Text;
namespace Dapper
{
@@ -104,7 +106,7 @@ public Template AddTemplate(string sql, dynamic parameters = null)
return new Template(this, sql, parameters);
}
- void AddClause(string name, string sql, object parameters, string joiner, string prefix = "", string postfix = "", bool isInclusive = false)
+ void AddClause(string name, string sql, object parameters, string joiner, string prefix = "", string postfix = "", bool IsInclusive = false)
{
Clauses clauses;
if (!data.TryGetValue(name, out clauses))
@@ -112,7 +114,7 @@ void AddClause(string name, string sql, object parameters, string joiner, string
clauses = new Clauses(joiner, prefix, postfix);
data[name] = clauses;
}
- clauses.Add(new Clause { Sql = sql, Parameters = parameters, IsInclusive = isInclusive });
+ clauses.Add(new Clause { Sql = sql, Parameters = parameters, IsInclusive = IsInclusive });
seq++;
}
@@ -148,7 +150,7 @@ public SqlBuilder Where(string sql, dynamic parameters = null)
public SqlBuilder OrWhere(string sql, dynamic parameters = null)
{
- AddClause("where", sql, parameters, " AND ", prefix: "WHERE ", postfix: "\n", isInclusive: true);
+ AddClause("where", sql, parameters, " AND ", prefix: "WHERE ", postfix: "\n", IsInclusive: true);
return this;
}
diff --git a/DapperTests NET35/Properties/AssemblyInfo.cs b/DapperTests NET35/Properties/AssemblyInfo.cs
index a7296bf8c8a3a2380b6ac9801ba2df594d77f7ed..56ab18b186290df7e7be7d097a07ab7708e22668 100644
--- a/DapperTests NET35/Properties/AssemblyInfo.cs
+++ b/DapperTests NET35/Properties/AssemblyInfo.cs
@@ -1,4 +1,5 @@
using System.Reflection;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
diff --git a/Tests/Assert.cs b/Tests/Assert.cs
index 653467b8e597e37d4add76111c4e214e25bc2f91..96493f2d488401e88e902a59bcf87f0b4f8a6fe9 100644
--- a/Tests/Assert.cs
+++ b/Tests/Assert.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Text;
#if DNXCORE50
using ApplicationException = global::System.InvalidOperationException;
diff --git a/Tests/Massive/Massive.cs b/Tests/Massive/Massive.cs
index e10e7a291d0e83ec203580522c9112c4c1132ae0..44106ff16812ad00054154594a8f3277359c69d4 100644
--- a/Tests/Massive/Massive.cs
+++ b/Tests/Massive/Massive.cs
@@ -1,11 +1,14 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
+using System.Configuration;
using System.Data;
using System.Data.Common;
using System.Dynamic;
using System.Linq;
using System.Text;
+using System.Collections;
+using System.Text.RegularExpressions;
namespace Massive
{
@@ -34,13 +37,13 @@ public static void AddParam(this DbCommand cmd, object item)
}
else
{
- if (item is Guid)
+ if (item.GetType() == typeof(Guid))
{
p.Value = item.ToString();
p.DbType = DbType.String;
p.Size = 4000;
}
- else if (item is ExpandoObject)
+ else if (item.GetType() == typeof(ExpandoObject))
{
var d = (IDictionary)item;
p.Value = d.Values.FirstOrDefault();
@@ -50,7 +53,7 @@ public static void AddParam(this DbCommand cmd, object item)
p.Value = item;
}
//from DataChomp
- if (item is string)
+ if (item.GetType() == typeof(string))
p.Size = 4000;
}
cmd.Parameters.Add(p);
@@ -82,7 +85,7 @@ public static dynamic ToExpando(this object o)
{
var result = new ExpandoObject();
var d = result as IDictionary; //work with the Expando as a Dictionary
- if (o is ExpandoObject) return o; //shouldn't have to... but just in case
+ if (o.GetType() == typeof(ExpandoObject)) return o; //shouldn't have to... but just in case
if (o.GetType() == typeof(NameValueCollection) || o.GetType().IsSubclassOf(typeof(NameValueCollection)))
{
var nv = (NameValueCollection)o;
@@ -148,7 +151,7 @@ public virtual IEnumerable Query(string sql, params object[] args)
var rdr = CreateCommand(sql, conn, args).ExecuteReader();
while (rdr.Read())
{
- yield return rdr.RecordToExpando();
+ yield return rdr.RecordToExpando(); ;
}
}
}
@@ -158,7 +161,7 @@ public virtual IEnumerable Query(string sql, DbConnection connection, p
{
while (rdr.Read())
{
- yield return rdr.RecordToExpando();
+ yield return rdr.RecordToExpando(); ;
}
}
@@ -417,7 +420,7 @@ public virtual dynamic Paged(string where = "", string orderBy = "", string colu
where = "WHERE " + where;
}
}
- var sql = string.Format("SELECT {0} FROM (SELECT ROW_NUMBER() OVER (ORDER BY {2}) AS Row, {0} FROM {3} {4}) AS Paged ", columns, orderBy, TableName, where);
+ var sql = string.Format("SELECT {0} FROM (SELECT ROW_NUMBER() OVER (ORDER BY {2}) AS Row, {0} FROM {3} {4}) AS Paged ", columns, pageSize, orderBy, TableName, where);
var pageStart = (currentPage - 1) * pageSize;
sql += string.Format(" WHERE Row >={0} AND Row <={1}", pageStart, (pageStart + pageSize));
countSQL += where;
diff --git a/Tests/NHibernate/NHibernateHelper.cs b/Tests/NHibernate/NHibernateHelper.cs
index 9917dd2077899e6e4e8822c405627ce6302bfa66..d1773d765b45a672af99035d599d5d44f7829af4 100644
--- a/Tests/NHibernate/NHibernateHelper.cs
+++ b/Tests/NHibernate/NHibernateHelper.cs
@@ -1,4 +1,5 @@
-using NHibernate;
+using System.Data;
+using NHibernate;
using NHibernate.Cfg;
namespace SqlMapper.NHibernate
diff --git a/Tests/PerformanceTests.cs b/Tests/PerformanceTests.cs
index 239b9d15f3bf39eca43ca8f16206b07dede9d74a..6ca8752cc67c8030f2c2093eb09b749785cd3133 100644
--- a/Tests/PerformanceTests.cs
+++ b/Tests/PerformanceTests.cs
@@ -174,7 +174,8 @@ public void Run(int iterations)
var nhSession4 = NHibernateHelper.OpenSession();
tests.Add(id => nhSession4
- .Query().First(p => p.Id == id), "NHibernate LINQ");
+ .Query()
+ .Where(p => p.Id == id).First(), "NHibernate LINQ");
var nhSession5 = NHibernateHelper.OpenSession();
tests.Add(id => nhSession5.Get(id), "NHibernate Session.Get");
@@ -313,7 +314,7 @@ public static string GetNullableString(this SqlDataReader reader, int index)
return null;
}
- public static T? GetNullableValue(this SqlDataReader reader, int index) where T : struct
+ public static Nullable GetNullableValue(this SqlDataReader reader, int index) where T : struct
{
object tmp = reader.GetValue(index);
if (tmp != DBNull.Value)
diff --git a/Tests/PetaPoco/PetaPoco.cs b/Tests/PetaPoco/PetaPoco.cs
index 80072921dbb184a5055a5d6cb80af8836d60019a..f7584e3758c6849668840837fdd77ef8367d54ce 100644
--- a/Tests/PetaPoco/PetaPoco.cs
+++ b/Tests/PetaPoco/PetaPoco.cs
@@ -283,13 +283,13 @@ static void AddParam(DbCommand cmd, object item, string ParameterPrefix)
}
else
{
- if (item is Guid)
+ if (item.GetType() == typeof(Guid))
{
p.Value = item.ToString();
p.DbType = DbType.String;
p.Size = 4000;
}
- else if (item is string)
+ else if (item.GetType() == typeof(string))
{
p.Size = (item as string).Length + 1;
if (p.Size < 4000)
@@ -344,13 +344,13 @@ public DbCommand CreateCommand(DbConnection connection, string sql, params objec
}
else
{
- if (item is Guid)
+ if (item.GetType() == typeof(Guid))
{
p.Value = item.ToString();
p.DbType = DbType.String;
p.Size = 4000;
}
- else if (item is string)
+ else if (item.GetType() == typeof(string))
{
p.Size = (item as string).Length + 1;
if (p.Size < 4000)
@@ -1034,7 +1034,7 @@ public string LastCommand
sb.Append("\r\n\r\n");
for (int i = 0; i < _lastArgs.Length; i++)
{
- sb.AppendFormat("{0} - {1}\r\n", i, _lastArgs[i]);
+ sb.AppendFormat("{0} - {1}\r\n", i, _lastArgs[i].ToString());
}
}
return sb.ToString();
@@ -1185,13 +1185,13 @@ public PocoData(Type t)
// Standard DateTime->Utc mapper
if (ForceDateTimesToUtc && converter == null && srcType == typeof(DateTime) && (dstType == typeof(DateTime) || dstType == typeof(DateTime?)))
{
- converter = src => new DateTime(((DateTime) src).Ticks, DateTimeKind.Utc);
+ converter = delegate(object src) { return new DateTime(((DateTime)src).Ticks, DateTimeKind.Utc); };
}
// Forced type conversion
if (converter == null && !dstType.IsAssignableFrom(srcType))
{
- converter = src => Convert.ChangeType(src, dstType, null);
+ converter = delegate(object src) { return Convert.ChangeType(src, dstType, null); };
}
// Fast
@@ -1222,10 +1222,11 @@ public PocoData(Type t)
if (!Handled)
{
// Setup stack for call to converter
- if (converter != null)
+ int converterIndex = -1;
+ if (converter != null)
{
// Add the converter
- var converterIndex = m_Converters.Count;
+ converterIndex = m_Converters.Count;
m_Converters.Add(converter);
// Generate IL to push the converter onto the stack
diff --git a/Tests/SubSonic/ActiveRecord.cs b/Tests/SubSonic/ActiveRecord.cs
index ccdf6eb6b0d3f25e16b0f85ee100127b6405c56a..0e125239fe3742b41b164a9167048524543e2ab0 100644
--- a/Tests/SubSonic/ActiveRecord.cs
+++ b/Tests/SubSonic/ActiveRecord.cs
@@ -141,8 +141,12 @@ public partial class Post: IActiveRecord
internal static IRepository GetRepo(string connectionString, string providerName){
- tempdbDB db;
- db = String.IsNullOrEmpty(connectionString) ? new tempdbDB() : new tempdbDB(connectionString, providerName);
+ SubSonic.tempdbDB db;
+ if(String.IsNullOrEmpty(connectionString)){
+ db=new SubSonic.tempdbDB();
+ }else{
+ db=new SubSonic.tempdbDB(connectionString, providerName);
+ }
IRepository _repo;
if(db.TestMode){
@@ -162,7 +166,7 @@ public partial class Post: IActiveRecord
var repo = GetRepo();
var results=repo.Find(expression);
Post single=null;
- if(results.Any()){
+ if(results.Count() > 0){
single=results.ToList()[0];
single.OnLoaded();
single.SetIsLoaded(true);
@@ -176,7 +180,7 @@ public partial class Post: IActiveRecord
var repo = GetRepo(connectionString,providerName);
var results=repo.Find(expression);
Post single=null;
- if(results.Any()){
+ if(results.Count() > 0){
single=results.ToList()[0];
}
@@ -251,7 +255,7 @@ public object KeyValue()
}
public override string ToString(){
- return this.Text;
+ return this.Text.ToString();
}
public override bool Equals(object obj){
@@ -270,7 +274,7 @@ public object KeyValue()
public string DescriptorValue()
{
- return this.Text;
+ return this.Text.ToString();
}
public string DescriptorColumn() {
diff --git a/Tests/SubSonic/Context.cs b/Tests/SubSonic/Context.cs
index f153e97a2f73c4d95337a775c72efa4d01824049..dc8ea8729df48ae3a572ce704898e2a810a867f8 100644
--- a/Tests/SubSonic/Context.cs
+++ b/Tests/SubSonic/Context.cs
@@ -31,9 +31,14 @@ public bool TestMode
}
}
- public tempdbDB()
+ public tempdbDB()
{
- DataProvider = DefaultDataProvider ?? ProviderFactory.GetProvider("Smackdown.Properties.Settings.tempdbConnectionString");
+ if (DefaultDataProvider == null) {
+ DataProvider = ProviderFactory.GetProvider("Smackdown.Properties.Settings.tempdbConnectionString");
+ }
+ else {
+ DataProvider = DefaultDataProvider;
+ }
Init();
}
diff --git a/Tests/SubSonic/Structs.cs b/Tests/SubSonic/Structs.cs
index 00d4e0441aa2cb5b8e36817a80b48bbd655374ef..a3f87ff1451981bd8ff3241f9f980173d8319546 100644
--- a/Tests/SubSonic/Structs.cs
+++ b/Tests/SubSonic/Structs.cs
@@ -1,4 +1,9 @@
+
+
+
+using System;
using SubSonic.Schema;
+using System.Collections.Generic;
using SubSonic.DataProviders;
using System.Data;