Skip to content

Commit

Permalink
Reverting change of using varchar of default parameter type as it bre…
Browse files Browse the repository at this point in the history
…aks SQL Server CE
  • Loading branch information
lahma committed Aug 28, 2010
1 parent 216f698 commit 223713c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
6 changes: 1 addition & 5 deletions src/Quartz/Impl/AdoJobStore/AdoUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

using System;
using System.Data;
using System.Reflection;

namespace Quartz.Impl.AdoJobStore
{
Expand All @@ -30,12 +29,10 @@ namespace Quartz.Impl.AdoJobStore
public class AdoUtil
{
private readonly IDbProvider dbProvider;
private MethodInfo commandParameterTypeSetMethod;

public AdoUtil(IDbProvider dbProvider)
{
this.dbProvider = dbProvider;
this.commandParameterTypeSetMethod = dbProvider.Metadata.ParameterDbTypeProperty.GetSetMethod();
}

public void AddCommandParameter(IDbCommand cmd, string paramName, object paramValue)
Expand All @@ -50,7 +47,6 @@ public void AddCommandParameter(IDbCommand cmd, string paramName, object paramVa
{
SetDataTypeToCommandParameter(param, dataType);
}

param.ParameterName = dbProvider.Metadata.GetParameterName(paramName);
param.Value = paramValue ?? DBNull.Value;
cmd.Parameters.Add(param);
Expand All @@ -64,7 +60,7 @@ public void AddCommandParameter(IDbCommand cmd, string paramName, object paramVa

private void SetDataTypeToCommandParameter(IDbDataParameter param, object parameterType)
{
commandParameterTypeSetMethod.Invoke(param, new object[] { parameterType });
dbProvider.Metadata.ParameterDbTypeProperty.GetSetMethod().Invoke(param, new object[] { parameterType });
}

public IDbCommand PrepareCommand(ConnectionAndTransactionHolder cth, string commandText)
Expand Down
23 changes: 0 additions & 23 deletions src/Quartz/Impl/AdoJobStore/StdAdoDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2921,30 +2921,7 @@ protected virtual void AddCommandParameter(IDbCommand cmd, string paramName, obj

protected virtual void AddCommandParameter(IDbCommand cmd, string paramName, object paramValue, Enum dataType)
{
if (dataType == null && paramValue is string)
{
// performance optimization for database
// default type is nvarchar that may cause unwanted index performance issues
// when column type is varchar and parameter is nvarchar
// this may cause a index scan instead of an index seek
dataType = DefaultStringDbType;
}

adoUtil.AddCommandParameter(cmd, paramName, paramValue, dataType);
}

/// <summary>
/// Returns the value of <see cref="DbType" /> enumeration that describes
/// the default db type for strings. The Default in .NET is NVARCHAR (unicode)
/// but Quartz.NET uses VARCHAR (ansi string) for index performance reasons.
/// </summary>
/// <remarks>
/// See http://dylanbeattie.blogspot.com/2010/02/fun-and-games-with-nhibernate-and.html .
/// </remarks>
/// <value></value>
protected virtual DbType DefaultStringDbType
{
get { return DbType.AnsiString; }
}
}
}

0 comments on commit 223713c

Please sign in to comment.