From e1dcf6b06145ca7b21f355dbc2e35ce0fc5c2c7a Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 7 Oct 2014 11:50:35 +1100 Subject: [PATCH] reverts IQuery --- .../Persistence/Querying/IQuery.cs | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Core/Persistence/Querying/IQuery.cs b/src/Umbraco.Core/Persistence/Querying/IQuery.cs index b484465540..b158943cb4 100644 --- a/src/Umbraco.Core/Persistence/Querying/IQuery.cs +++ b/src/Umbraco.Core/Persistence/Querying/IQuery.cs @@ -4,6 +4,28 @@ using System.Linq.Expressions; namespace Umbraco.Core.Persistence.Querying { + /// + /// SD: This is a horrible hack but unless we break compatibility with anyone who's actually implemented IQuery{T} there's not much we can do. + /// The IQuery{T} interface is useless without having a GetWhereClauses method and cannot be used for tests. + /// We have to wait till v8 to make this change I suppose. + /// + internal static class QueryExtensions + { + /// + /// Returns all translated where clauses and their sql parameters + /// + /// + public static IEnumerable> GetWhereClauses(this IQuery query) + { + var q = query as Query; + if (q == null) + { + throw new NotSupportedException(typeof(IQuery) + " cannot be cast to " + typeof(Query)); + } + return q.GetWhereClauses(); + } + } + /// /// Represents a query for building Linq translatable SQL queries /// @@ -17,10 +39,6 @@ namespace Umbraco.Core.Persistence.Querying /// This instance so calls to this method are chainable IQuery Where(Expression> predicate); - /// - /// Returns all translated where clauses and their sql parameters - /// - /// - IEnumerable> GetWhereClauses(); + } } \ No newline at end of file