public string Translate([NotNull] DslFormatBlock queryBlock)
        {
            if (queryBlock == null)
            {
                throw new ArgumentNullException(nameof(queryBlock));
            }

            var stringBUilder = new StringBuilder();

            stringBUilder.Append(".AsEnumerable().Select(x => new {");

            foreach (var selectItemExpr in queryBlock.Selects)
            {
                var value = _queryVariableNameBuilder.ToProperty(selectItemExpr.Value);

                var nameSpecified = !string.IsNullOrWhiteSpace(selectItemExpr.Name);

                stringBUilder.Append(nameSpecified
                                        ? $"{selectItemExpr.Name}={value},"
                                        : $"{value},");
            }

            stringBUilder.AppendLine("})");

            return(stringBUilder.ToString());
        }
Пример #2
0
        public string Translate([NotNull] FilterConstantSpecification specification)
        {
            if (specification == null)
            {
                throw new ArgumentNullException(nameof(specification));
            }

            return(_queryVariableNameBuilder.IsProperty(specification.Value)
                                ? _queryVariableNameBuilder.ToProperty(specification.Value)
                                : specification.Value);
        }
        public string Translate([NotNull] DslGroupBlock queryBlock)
        {
            if (queryBlock == null)
            {
                throw new ArgumentNullException(nameof(queryBlock));
            }

            var properties = queryBlock.Items.Select(_ =>
                                                     _queryVariableNameBuilder.ToProperty(
                                                         _queryVariableNameBuilder.Encode(_.VariableName)));

            return($".GroupBy(x => new{{{string.Join(",", properties)}}})");
        }