/// <summary>
        /// Convert expression to code.
        /// </summary>
        /// <param name="expression">Expression.</param>
        /// <param name="converter">Expression converter.</param>
        /// <returns>Parts.</returns>
        public override ICode Convert(MethodCallExpression expression, ExpressionConverter converter)
        {
            //TODO これちょっとおかしい
            var startIndex = expression.SkipMethodChain(0);
            var table      = FromConverterAttribute.ConvertTable(converter, expression.Arguments[startIndex]);

            if (table.IsEmpty)
            {
                return(string.Empty.ToCode());
            }

            var condition = ((startIndex + 1) < expression.Arguments.Count) ? converter.ConvertToCode(expression.Arguments[startIndex + 1]) : null;

            var join = new HCode()
            {
                AddIndentNewLine = true, Separator = " ", Indent = 1
            };

            join.Add(_nameCode);
            join.Add(table);
            if (condition != null)
            {
                join.Add("ON".ToCode());
                join.Add(condition);
            }
            return(join);
        }
        /// <summary>
        /// Convert expression to code.
        /// </summary>
        /// <param name="expression">Expression.</param>
        /// <param name="converter">Expression converter.</param>
        /// <returns>Parts.</returns>
        public override ICode Convert(MethodCallExpression expression, ExpressionConverter converter)
        {
            var name     = FromConverterAttribute.GetSubQuery(expression.Arguments[0]);
            var coreType = expression.Arguments[0].Type.GetGenericArgumentsEx()[0];
            var info     = ObjectCreateAnalyzer.MakeObjectCreateInfo(coreType);

            //TODO
            return(new WithEntriedCode(Line(name.ToCode(), Blanket(info.Members.Select(e => e.Name.ToCode()).ToArray())), new[] { name }));
        }
示例#3
0
        static ICode ConvertNormalWith(ExpressionConverter converter, NewArrayExpression arry)
        {
            var with = new VCode()
            {
                Indent = 1, Separator = ","
            };
            var names = new List <string>();

            foreach (var e in arry.Expressions)
            {
                var table = converter.ConvertToCode(e);
                var body  = FromConverterAttribute.GetSubQuery(e);
                names.Add(body);
                with.Add(Clause(LineSpace(body.ToCode(), "AS".ToCode()), table));
            }
            return(new WithEntriedCode(new VCode("WITH".ToCode(), with), names.ToArray()));
        }