-
Notifications
You must be signed in to change notification settings - Fork 933
* Basic support for T-SQL query hints. #3008
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,5 +38,12 @@ public interface IQueryableOptions | |
/// <param name="timeout">The timeout in seconds.</param> | ||
/// <returns><see langword="this" /> (for method chaining).</returns> | ||
IQueryableOptions SetTimeout(int timeout); | ||
|
||
/// <summary> | ||
/// Set a T-SQL Query hint as an Option to the query | ||
/// </summary> | ||
/// <param name="hint">The t-sql query hint</param> | ||
/// <returns><see langword="this" /> (for method chaining).</returns> | ||
IQueryableOptions SetHint(string hint); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This interface should not be changed. It is obsolete. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,6 +104,14 @@ protected override SqlString ApplyLocks(SqlString sql, IDictionary<string, LockM | |
return dialect.ApplyLocksToSql(sql, aliasedLockModes, keyColumnNames); | ||
} | ||
|
||
protected override SqlString ApplyHint(SqlString sql, string hint, Dialect.Dialect dialect) | ||
{ | ||
if (dialect.SupportsQueryHints) | ||
return dialect.GetQueryHintString(sql, hint); | ||
|
||
return base.ApplyHint(sql, hint, dialect); | ||
} | ||
|
||
protected override string[] Aliases | ||
{ | ||
get { return _sqlAliases; } | ||
|
@@ -343,9 +351,9 @@ protected override object GetResultColumnOrRow(object[] row, IResultTransformer | |
Object[] resultRow = GetResultRow(row, rs, session); | ||
bool hasTransform = HasSelectNew || resultTransformer != null; | ||
return (!hasTransform && resultRow.Length == 1 | ||
? resultRow[0] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert these changes. |
||
: resultRow | ||
); | ||
? resultRow[0] | ||
: resultRow | ||
); | ||
} | ||
|
||
protected override object[] GetResultRow(object[] row, DbDataReader rs, ISessionImplementor session) | ||
|
@@ -441,7 +449,7 @@ internal IEnumerable GetEnumerable(QueryParameters queryParameters, IEventSource | |
var rs = GetResultSet(cmd, queryParameters, session, null); | ||
|
||
var resultTransformer = _selectNewTransformer ?? queryParameters.ResultTransformer; | ||
IEnumerable result = | ||
IEnumerable result = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert this changes |
||
new EnumerableImpl(rs, cmd, session, queryParameters.IsReadOnly(session), _queryTranslator.ReturnTypes, _queryTranslator.GetColumnNames(), queryParameters.RowSelection, resultTransformer, _queryReturnAliases); | ||
|
||
if (stopWatch != null) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -227,6 +227,16 @@ protected virtual SqlString ApplyLocks(SqlString sql, IDictionary<string, LockMo | |
return sql; | ||
} | ||
|
||
/// <summary> | ||
/// Append <c> OPTION(...hints...)</c> clause, if necessary. This | ||
/// empty superclass implementation merely returns its first | ||
/// argument. | ||
/// </summary> | ||
protected virtual SqlString ApplyHint(SqlString sql, string hints, Dialect.Dialect dialect) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method is not used anywhere. |
||
{ | ||
return sql; | ||
} | ||
|
||
/// <summary> | ||
/// Does this query return objects that might be already cached by | ||
/// the session, whose lock mode may need upgrading. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a strange place to add query hint...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be a better place?