/// <summary> /// Handle IQuery before execute /// </summary> /// <param name="query">Query object</param> /// <param name="usageScene">Usage scene</param> /// <param name="queryHandler">Query handler</param> /// <returns>Return the real query object to use</returns> internal static IQuery HandleQueryObjectBeforeExecute(IQuery query, QueryUsageScene usageScene, Func <IQuery, IQuery> queryHandler = null) { var newQuery = query?.DeepCopy(); if (queryHandler != null) { newQuery = queryHandler(newQuery); } return(newQuery); }
/// <summary> /// Append repository condition /// </summary> /// <param name="originalQuery">Original query</param> /// <returns>Return the newest query object</returns> IQuery AppendRepositoryCondition(IQuery originalQuery, QueryUsageScene usageScene) { if (originalQuery == null) { originalQuery = QueryManager.Create(); originalQuery.SetEntityType(entityType); } else { originalQuery.SetEntityType(entityType); } //primary query GlobalConditionFilter conditionFilter = new GlobalConditionFilter() { OriginalQuery = originalQuery, UsageSceneEntityType = entityType, EntityType = entityType, SourceType = QuerySourceType.Repository, UsageScene = usageScene }; var conditionFilterResult = QueryManager.GetGlobalCondition(conditionFilter); if (conditionFilterResult != null) { conditionFilterResult.AppendTo(originalQuery); } //subqueries if (!originalQuery.Subqueries.IsNullOrEmpty()) { foreach (var squery in originalQuery.Subqueries) { AppendSubqueryCondition(squery, conditionFilter); } } //join if (!originalQuery.JoinItems.IsNullOrEmpty()) { foreach (var jitem in originalQuery.JoinItems) { AppendJoinQueryCondition(jitem.JoinQuery, conditionFilter); } } return(originalQuery); }
/// <summary> /// Handle IQuery after execute /// </summary> /// <param name="originalQuery">Original query</param> /// <param name="executeQuery">Execute query</param> /// <param name="usageScene">Usage scene</param> internal static void HandleQueryObjectAfterExecute(IQuery originalQuery, IQuery executeQuery, QueryUsageScene usageScene) { originalQuery?.Reset(); }