c:\workspace\company\kentico\source\kentico12\DataEngine\Database\Abstract\AbstractSqlGenerator.cs
// SELECT ALL query case SqlOperationTypeEnum.SelectAll: sb.Append(SqlHelper.GetSelectQuery(tableName)); break;
c:\workspace\company\kentico\source\kentico12\DataEngine\Database\Helpers\SqlHelper.cs
/// <summary> /// Gets the general select query /// </summary> /// <param name="source">Query source</param> /// <param name="where">Where condition</param> public static string GetSelectQuery(string source, string where = null) { var query = SqlMacroHelper.ReplaceSource(GENERAL_SELECT, source, null); if (!String.IsNullOrEmpty(where)) { query = SqlMacroHelper.ReplaceWhere(query, where, true); } return query; }
C:\workspace\Company\Kentico\Source\Kentico12\DataEngine\Database\Helpers\SqlMacroHelper.cs
/// <summary> /// Replaces the source macro in the query text /// </summary> /// <param name="queryText">Query text</param> /// <param name="source">Query source</param> /// <param name="defaultSource">Default source</param> public static string ReplaceSource(string queryText, string source, string defaultSource) { // Replace source if (!ReplaceMacro(ref queryText, QueryMacros.SOURCE, source, defaultSource) && !String.IsNullOrEmpty(source)) { throw new NotSupportedException("[SqlHelper.ReplaceSource]: Missing ##SOURCE## macro in the query text ‘" + queryText + "‘, cannot apply the source ‘" + source + "‘."); } return queryText; }
自己遇到的错误的堆栈信息是
Message: [SqlHelper.ReplaceColumns]: Missing ##COLUMNS## macro in the query text ‘
WITH AllData AS
(
SELECT
MLR.ItemID
,MLR.UserId
,TypeOfEmployment
,CardType
,WalletType
,CustomerNumber
,ConfirmationResultCode
,RepeatingAction
,CustomerID
,FirstName
,LastName
,Email
,SocialSecurityNumber
,EmployeeNumber
,City
,CostCenter
,Department
,StatusTR
,StatusTMB
,StatusTT
,StatusTD
,BalanceTR
,BalanceTMB
,BalanceTT
,BalanceTD_TR
,BalanceTD_TMB
,LoadValue
,LoadDate
,LoadWorkingDays
,LoadWorkingDaysValue
,LoadDay
,MLR.ItemCreatedWhen
,CASE WHEN IsNull(ConfirmationResultCode,-1)=0 THEN MLR.ItemModifiedWhen ELSE MLR.ItemCreatedWhen END TimeStamp
,DayOfMonthForLoad_TR
,DayOfMonthForLoad_TMB
,DayOfMonthForLoad_TD_TR
,DayOfMonthForLoad_TD_TMB
,DayOfMonthForLoad_TT
,PossibleValueChoice1_TR
,PossibleValueChoice2_TR
,PossibleValueChoice3_TR
,PossibleValueChoice1_TMB
,PossibleValueChoice2_TMB
,PossibleValueChoice3_TMB
,PossibleValueChoice1_TD_TR
,PossibleValueChoice2_TD_TR
,PossibleValueChoice3_TD_TR
,PossibleValueChoice1_TD_TMB
,PossibleValueChoice2_TD_TMB
,PossibleValueChoice3_TD_TMB
,PossibleValueChoice1_TT
,PossibleValueChoice2_TT
,PossibleValueChoice3_TT
,CardStatusTD
,WorkingDays_TR
,WorkingDays_TD_TR
,WorkingDaysCounter_TR
,WorkingDaysCounter_TD_TR
,WorkingDaysValueChoice1_TR
,WorkingDaysValueChoice2_TR
,WorkingDaysValueChoice3_TR
,WorkingDaysValueChoice1_TD_TR
,WorkingDaysValueChoice2_TD_TR
,WorkingDaysValueChoice3_TD_TR
,LoadPercentage
,EmploymentEndDate
,ScheduledDroppingDate
,ROW_NUMBER() over (order by lastname, firstname) as CMS_RN
FROM dbo.WOT_MyLodRequest MLR
INNER JOIN dbo.WOT_Company C ON C.Number = MLR.CustomerNumber
INNER JOIN dbo.MobileApplicationUser MAU ON MAU.UserID = MLR.UserId
INNER JOIN dbo.CMS_User U ON U.UserID =MLR.UserId
LEFT JOIN dbo.View_WOT_CardholderSettings CS ON CS.MAUItemId = MAU.ItemId
WHERE ##WHERE##
)
SELECT *, (SELECT COUNT(*) FROM AllData) AS [CMS_TOT]
FROM AllData
WHERE CMS_RN BETWEEN 1 AND 25
ORDER BY CMS_RN
‘, cannot apply the specified columns ‘*, ROW_NUMBER() OVER (ORDER BY [LastName], [Firstname]) AS [CMS_RN]‘.
Exception type: System.NotSupportedException
Stack trace:
at CMS.DataEngine.SqlMacroHelper.ReplaceColumns(String queryText, String columns)
at CMS.DataEngine.SqlMacroHelper.ResolveMacrosInQueryText(QueryMacros queryMacros, String queryText)
at CMS.DataEngine.SqlMacroHelper.ResolveQueryMacros(QueryMacros queryMacros, String queryText)
at CMS.DataEngine.QueryParameters.ResolveMacrosInternal(Boolean updateQueryText)
at CMS.DataEngine.GeneralConnection.ExecuteQuery(QueryParameters query)
at CMS.DataEngine.GeneralConnection.ExecuteQuery(QueryParameters query, Int32& totalRecords)
at CMS.DataEngine.DataQueryBase`1.GetDataFromDBInternal()
at CMS.DataEngine.DataQueryBase`1.GetDataFromDB()
at CMS.DataEngine.DataQueryBase`1.GetData()
at CMS.DataEngine.DataQueryBase`1.get_Result()
at CMS.DataEngine.ConnectionHelper.ExecuteQuery(String queryName, QueryDataParameters parameters, String where, String orderBy, Int32 topN, String columns, Int32 offset, Int32 maxRecords, Int32& totalRecords)
at CMS.UIControls.UniGrid.LoadDataFromQuery()
at CMS.UIControls.UniGrid.RetrieveData()
at CMS.UIControls.UniGrid.ReloadData()