Fix tracked reference queries for SqlServer (#16020)
* Fixed issue with SqlServer and optimized queries to not do the actual paging if total count is 0 * Cleanup --------- Co-authored-by: Elitsa <elm@umbraco.dk>
This commit is contained in:
@@ -77,7 +77,8 @@ internal static class UmbracoDatabaseExtensions
|
||||
|
||||
public static long Count(this IUmbracoDatabase database, Sql sql)
|
||||
{
|
||||
var query = new Sql().Select("COUNT(*)").From().Append("(").Append(sql).Append(")");
|
||||
// We need to copy the sql into a new object, to avoid this method from changing the sql.
|
||||
var query = new Sql().Select("COUNT(*)").From().Append("(").Append(new Sql(sql.SQL, sql.Arguments)).Append(") as count_query");
|
||||
|
||||
return database.ExecuteScalar<long>(query);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user