Пример #1
0
        public object Execute(Query.IContentQuery <Models.TextContent> query)
        {
            var translator = new QueryProcessor.TextContentTranslator();
            var executor   = translator.Translate(query);
            var result     = executor.Execute();

            return(result);
        }
Пример #2
0
        public object Execute(Query.IContentQuery <Models.TextContent> query)
        {
            /*
             * Categories
             * SELECT * FROM [ef1].[dbo].[Test2] category
             * WHERE  EXISTS(
             *          SELECT ContentCategory.CategoryUUID
             *              FROM [fullips.__ContentCategory] ContentCategory,
             *                  (SELECT * FROM [ef1].[dbo].[Tests] content WHERE ([UUID] = 'F562CCDW9FGM53WE') AND FolderName='Test' )content
             *              WHERE content.UUID = ContentCategory.UUID AND ContentCategory.CategoryUUID = category.UUID
             *        ) AND 1=1 AND FolderName='Test2' ORDER BY Id DESC
             *
             */

            object result = null;

            //Get content from API service
            //
            if (query is TextContentQuery && ((TextContentQuery)query).Folder != null && ((TextContentQuery)query).Folder.GetActualFolder().StoreInAPI)
            {
                var folder = ((TextContentQuery)query).Folder;
                var schema = ((Kooboo.CMS.Content.Query.TextContentQuery)query).Schema;

                if (query.Expression is Query.Expressions.CallExpression)
                {
                    result = GetResult(folder, schema, (Expression)query.Expression, ((Query.Expressions.CallExpression)query.Expression).CallType);
                }
                else if (query.Expression is Query.Expressions.TakeExpression ||
                         query.Expression is Kooboo.CMS.Content.Query.Expressions.OrderExpression)
                {
                    result = GetResult(folder, schema, (Expression)query.Expression, Kooboo.CMS.Content.Query.Expressions.CallType.Unspecified);
                }
                if (result == null)
                {
                    return new TextContent[] {}
                }
                ;

                return(result);
            }

            var translator = new QueryProcessor.TextContentTranslator();
            var executor   = translator.Translate(query);

            result = executor.Execute();

            return(result);
        }
Пример #3
0
        private IEnumerable <string> GetCategoryClause(Repository repository, IEnumerable <IContentQuery <TextContent> > categoryQueries, List <Parameter> parameters)
        {
            TextContentTranslator translator        = new TextContentTranslator();
            List <string>         categoryQueryList = new List <string>();

            foreach (var categoryQuery in categoryQueries)
            {
                var executor        = translator.Translate(categoryQuery);
                var categoryVisitor = new SQLServerVisitor <TextContent>(parameters);
                categoryVisitor.Visite(categoryQuery.Expression);

                IEnumerable <Parameter> outParameters;
                var categoryQuerySQL = executor.BuildQuerySQL(categoryVisitor, out outParameters);

                categoryQueryList.Add(string.Format(@"EXISTS(
                        SELECT ContentCategory.CategoryUUID 
                            FROM [{0}] ContentCategory,
                                ({1})category
                            WHERE content.UUID = ContentCategory.UUID AND ContentCategory.CategoryUUID = category.UUID 
                      )", repository.GetCategoryTableName()
                                                    , categoryQuerySQL));
            }
            return(categoryQueryList);
        }