Inheritance: Kooboo.CMS.Content.Query.Translator.ExpressionVisitor
Exemplo n.º 1
0
        public object Execute(IContentQuery<MediaContent> query)
        {
            var mediaQuery = (MediaContentQuery)query;

            var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();

            QueryExpressionTranslator translator = new QueryExpressionTranslator();

            var blobs = translator.Translate(query.Expression, blobClient, mediaQuery.MediaFolder)
                .Where(it => it != null)
                .Select(it => it.BlobToMediaContent(new MediaContent(mediaQuery.Repository.Name, mediaQuery.MediaFolder.FullName)));
            //translator.Visite(query.Expression);

            switch (translator.CallType)
            {
                case CallType.Count:
                    return blobs.Count();
                case CallType.First:
                    return blobs.First();
                case CallType.Last:
                    return blobs.Last();
                case CallType.LastOrDefault:
                    return blobs.LastOrDefault();
                case CallType.FirstOrDefault:
                    return blobs.FirstOrDefault();
                case CallType.Unspecified:
                default:
                    return blobs;
            }
        }
Exemplo n.º 2
0
        public object Execute(IContentQuery <MediaContent> query)
        {
            var mediaQuery = (MediaContentQuery)query;

            var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();

            QueryExpressionTranslator translator = new QueryExpressionTranslator();

            var blobs = translator.Translate(query.Expression, blobClient, mediaQuery.MediaFolder)
                        .Where(it => it != null)
                        .Select(it => it.BlobToMediaContent(new MediaContent(mediaQuery.Repository.Name, mediaQuery.MediaFolder.FullName)));

            foreach (var item in translator.OrderFields)
            {
                if (item.Descending)
                {
                    blobs = blobs.OrderByDescending(it => it.GetType().GetProperty(item.FieldName).GetValue(it, null));
                }
                else
                {
                    blobs = blobs.OrderBy(it => it.GetType().GetProperty(item.FieldName).GetValue(it, null));
                }
            }
            //translator.Visite(query.Expression);

            switch (translator.CallType)
            {
            case CallType.Count:
                return(blobs.Count());

            case CallType.First:
                return(blobs.First());

            case CallType.Last:
                return(blobs.Last());

            case CallType.LastOrDefault:
                return(blobs.LastOrDefault());

            case CallType.FirstOrDefault:
                return(blobs.FirstOrDefault());

            case CallType.Unspecified:
            default:
                return(blobs);
            }
        }
Exemplo n.º 3
0
        public object Execute(IContentQuery <MediaContent> query)
        {
            var mediaQuery = (MediaContentQuery)query;

            var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();

            QueryExpressionTranslator translator = new QueryExpressionTranslator();

            var blobs = translator.Translate(query.Expression, blobClient, mediaQuery.MediaFolder)
                        .Where(it => it != null)
                        .Select(it => it.BlobToMediaContent(new MediaContent(mediaQuery.Repository.Name, mediaQuery.MediaFolder.FullName)));

            //translator.Visite(query.Expression);

            switch (translator.CallType)
            {
            case CallType.Count:
                return(blobs.Count());

            case CallType.First:
                return(blobs.First());

            case CallType.Last:
                return(blobs.Last());

            case CallType.LastOrDefault:
                return(blobs.LastOrDefault());

            case CallType.FirstOrDefault:
                return(blobs.FirstOrDefault());

            case CallType.Unspecified:
            default:
                return(blobs);
            }
        }
Exemplo n.º 4
0
        public object Execute(IContentQuery<MediaContent> query)
        {
            var mediaQuery = (MediaContentQuery)query;

            var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();

            QueryExpressionTranslator translator = new QueryExpressionTranslator();

            var blobs = translator.Translate(query.Expression, blobClient, mediaQuery.MediaFolder)
                .Where(it => it != null)
                .Select(it => it.BlobToMediaContent(new MediaContent(mediaQuery.Repository.Name, mediaQuery.MediaFolder.FullName)));

            foreach (var item in translator.OrderFields)
            {
                if (item.Descending)
                {
                    blobs = blobs.OrderByDescending(it => it.GetType().GetProperty(item.FieldName).GetValue(it, null));
                }
                else
                {
                    blobs = blobs.OrderBy(it => it.GetType().GetProperty(item.FieldName).GetValue(it, null));
                }
            }
            //translator.Visite(query.Expression);

            switch (translator.CallType)
            {
                case CallType.Count:
                    return blobs.Count();
                case CallType.First:
                    return blobs.First();
                case CallType.Last:
                    return blobs.Last();
                case CallType.LastOrDefault:
                    return blobs.LastOrDefault();
                case CallType.FirstOrDefault:
                    return blobs.FirstOrDefault();
                case CallType.Unspecified:
                default:
                    return blobs;
            }
        }