private static void InnerTranslate(MemberExpression expression, QueryPack pack)
 {
     if (pack.Contains(expression.Expression.Type))
     {
         var table = pack.GetTable(expression.Expression.Type);
         pack.Append($"{table.Alias}.{expression.Member.Name}");
     }
     else
     {
         var name = expression.Member.Name;
         pack.Append($"@{name[0].ToString().ToUpperInvariant()}{name.Substring(1, name.Length - 1)}");
     }
 }
예제 #2
0
        private void TranslateTop(QuerySegment segment)
        {
            this.pack.State = QueryState.Select;
            this.pack.AppendFormat("SELECT TOP ({0}) ", segment.Count.ToString());

            var table = pack.GetTable(segment.Type);

            if (segment.Expression == null)
            {
                this.pack.AppendFormat("{0}.* ", table.Alias);
            }
            else
            {
                ExpressionTranslator.Translate(segment.Expression.Body, pack);
                pack.Append(string.Join(", ", pack.SelectFields));
                pack.SelectFields.Clear();
            }

            this.pack.AppendFormat(" FROM {0} AS {1}", table.Name, table.Alias);
        }
        private static void Select(MemberExpression expression, QueryPack pack)
        {
            var table = pack.GetTable(expression.Member.DeclaringType);

            pack.SelectFields.Add($"{table.Alias}.{expression.Member.Name}");
        }