public IEnumerable <QueryResultColumn> Evaluate(DslDataQuery query, long userId)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            var entityType = _queryEntityNameTranslator.GetEntityType(query.QueryEntityName);

            var dataSource = _dataSourceInfoProvider.Get(entityType.Name, userId);

            if (dataSource == null)
            {
                return(Enumerable.Empty <QueryResultColumn>());
            }

            var isQueryBlocksIsEmpty = (query.Blocks == null) ||
                                       !query.Blocks.Any();

            if (isQueryBlocksIsEmpty)
            {
                return(GetDefaultColumns(query, userId, dataSource));
            }

            RestrictFirstSelect(query, dataSource, userId);

            _queryProjectRestrictor.Restrict(query, entityType, dataSource, userId);

            return(GetLastSelectColumns(query));
        }
Пример #2
0
        private object ExecuteExpr(DslDataQuery query)
        {
            var linqQuery  = _translator.Translate(query);
            var entityType = _nameTranslator.GetEntityType(query.QueryEntityName);
            var source     = _dataSourceProvider.GetDataSource(entityType);

            var result = _executor.Execute(source, entityType, linqQuery);

            return(result);
        }
        public string ResolvePropertyTypeName(string entityTypeName, string propertyName)
        {
            var entityType = _queryEntityNameTranslator.GetEntityType(entityTypeName);

            var property = entityType.GetProperty(propertyName);

            if (property == null)
            {
                throw new PropertyDoesNotBelongsToEntityException(entityTypeName, propertyName);
            }

            if (property.PropertyType.IsGenericType)
            {
                return(property.PropertyType.GenericTypeArguments[0].Name);
            }

            var propertyTypeName = property.PropertyType.Name;

            return(propertyTypeName);
        }