本文整理汇总了C#中NHibernate.SqlCommand.SqlString.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# SqlString.Equals方法的具体用法?C# SqlString.Equals怎么用?C# SqlString.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.SqlCommand.SqlString
的用法示例。
在下文中一共展示了SqlString.Equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareBatchCommand
public IDbCommand PrepareBatchCommand(CommandType type, SqlString sql, SqlType[] parameterTypes)
{
/* NH:
* The code inside this block was added for a strange behaviour
* discovered using Firebird (some times for us is external issue).
* The problem is that batchCommandSql as a value, batchCommand is not null
* BUT batchCommand.CommandText is null (I don't know who clear it)
*/
bool forceCommandRecreate = batchCommand == null || string.IsNullOrEmpty(batchCommand.CommandText);
/****************************************/
if (sql.Equals(batchCommandSql) &&
ArrayHelper.ArrayEquals(parameterTypes, batchCommandParameterTypes) && !forceCommandRecreate)
{
if (log.IsDebugEnabled)
{
log.Debug("reusing command " + batchCommand.CommandText);
}
}
else
{
batchCommand = PrepareCommand(type, sql, parameterTypes); // calls ExecuteBatch()
batchCommandSql = sql;
batchCommandParameterTypes = parameterTypes;
}
return batchCommand;
}
示例2: RestoreMissingParameters
private void RestoreMissingParameters(SqlString originalSQL, ref SqlString transformedSQL)
{
if (originalSQL.Equals(transformedSQL))
{
return;
}
var parametersOriginal = new ArrayList();
var parametersTransformed = new ArrayList();
foreach (var part in originalSQL)
{
if (part is Parameter)
{
parametersOriginal.Add(part);
}
}
foreach (var part in transformedSQL)
{
if (part is Parameter)
{
parametersTransformed.Add(part);
}
}
//same number of parameters , return
if (parametersOriginal.Count == parametersTransformed.Count)
{
return;
}
//fix missing parameters spliting around '?'
var sqlText = transformedSQL.ToString();
Regex regex = new Regex("@x\\d+",
RegexOptions.IgnoreCase
| RegexOptions.CultureInvariant
);
var parametersParts = regex.Split(sqlText);
//parametersParts = sqlText.Split('?');
if ((parametersParts.Length - 1) != parametersOriginal.Count)
{
//can't restore
throw new QueryException("FinalizeJoins JetDriver removed SQL parameteres and can not be restored");
}
var sqlBuilder = new SqlStringBuilder();
for (int i = 0; i < parametersParts.Length; i++)
{
if (i > 0)
{
sqlBuilder.AddObject(parametersOriginal[i - 1]);
}
sqlBuilder.Add(parametersParts[i]);
}
transformedSQL = sqlBuilder.ToSqlString();
}
示例3: PrepareBatchCommand
public IDbCommand PrepareBatchCommand(CommandType type, SqlString sql, SqlType[] parameterTypes)
{
if (sql.Equals(batchCommandSql) &&
ArrayHelper.ArrayEquals(parameterTypes, batchCommandParameterTypes))
{
if (log.IsDebugEnabled)
{
log.Debug("reusing command " + batchCommand.CommandText);
}
}
else
{
batchCommand = PrepareCommand(type, sql, parameterTypes); // calls ExecuteBatch()
batchCommandSql = sql;
batchCommandParameterTypes = parameterTypes;
}
return batchCommand;
}
示例4: PrepareBatchCommand
/// <summary>
///
/// </summary>
/// <param name="sql"></param>
/// <returns></returns>
public IDbCommand PrepareBatchCommand( SqlString sql )
{
if( !sql.Equals( batchCommandSql ) )
{
batchCommand = PrepareCommand( sql ); // calls ExecuteBatch()
batchCommandSql = sql;
}
else
{
if( log.IsDebugEnabled )
{
log.Debug( "reusing command " + batchCommand.CommandText );
}
}
return batchCommand;
}