private static ProcessingResult LoadData(ProcessingResult result, Type dataType)
        {
            if (!result.IsSuccess)
            {
                return(ProcessingResult.Unsuccessful);
            }

            var loadedResult = result.IsSingleItem
                ? result.GetLoadedItem(dataType)
                : result.GetLoadedItems(dataType);

            return(new ProcessingResult(true, loadedResult, result.IsSingleItem));
        }
        internal static object ProcessQueries(NodeReference node, DataContext context, Expression queryExpression)
        {
            var queries = GetQueriesInTurn(queryExpression);
            var nodes   = DatabaseManager.GetEntitiesNodes(node, context);

            var result = new ProcessingResult(true, nodes);

            result = queries.Aggregate(result, (current, query) => ProcessQuery(query, current, context));

            if (result.IsDeferred())
            {
                return(result.IsSingleItem
                    ? result.GetLoadedItem(GetReturnParameterType(queries.Last()))
                    : result.GetLoadedItems(GetReturnParameterType(queries.Last())));
            }

            return(result.Result);
        }