コード例 #1
0
        public void ShouldReturnDataSourceField()
        {
            const long dataSourceId = 234;

            const long userId = 53;

            const long dataSourceFieldId = 5323;

            _tableColumnsRepository
            .Setup(_ => _.GetAvailableByTable(dataSourceId))
            .Returns(new[]
            {
                new TableColumns
                {
                    Id = dataSourceFieldId
                }
            }.AsQueryable());

            _dataSourceFieldAccessValidator.Setup(_ => _.CanReadSourceField(dataSourceFieldId, userId)).Returns(true);

            var result = _target.GetBySource(dataSourceId, userId).ToArray();

            result.Length.ShouldBeEquivalentTo(1);

            result[0].Id.ShouldBeEquivalentTo(dataSourceFieldId);
        }
コード例 #2
0
        public DataSourceFieldDto[] Execute(GetDataSourceFieldsQuery getDataQuery)
        {
            if (getDataQuery == null)
            {
                throw new ArgumentNullException(nameof(getDataQuery));
            }

            var fields = _dataSourceFieldInfoProvider.GetBySource(getDataQuery.DataSourceKey, _userPrincipal.Info.Id);

            return(fields.Select(_ => new DataSourceFieldDto
            {
                Description = _.Description,
                Id = _.Id,
                Key = _.Key,
                Name = _.Name,
                ReferencedDataSourceId = _.ReferenceTableId
            })
                   .OrderBy(_ => _.Name)
                   .ToArray());
        }
コード例 #3
0
        private IEnumerable <QueryResultColumn> GetDefaultColumns([NotNull] DslDataQuery query,
                                                                  long userId,
                                                                  DataSourceInfo dataSource)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            var availableFields = _dataSourceFieldInfoProvider.GetBySource(dataSource.Id, userId);

            var dslFormatBlock = CreateFormatExprFromFields(availableFields);

            query.Blocks = new IDslQueryBlock[] { dslFormatBlock };

            var columns = availableFields.Select(_ => new QueryResultColumn
            {
                Code        = _.Key,
                Description = _.Description,
                Name        = _.Name
            });

            return(columns);
        }