/// <summary>
 /// Select
 /// </summary>
 /// <param name="expression">表达式树</param>
 /// <param name="sqlPack">sql打包对象</param>
 /// <returns>SqlPack</returns>
 public override SqlPack Select(NewExpression expression, SqlPack sqlPack)
 {
     for (var i = 0; i < expression.Members.Count; i++)
     {
         var argument = expression.Arguments[i];
         var member   = expression.Members[i];
         SqlBuilderProvider.Select(argument, sqlPack);
         //添加字段别名
         if ((argument as MemberExpression)?.Member.Name != member.Name)
         {
             sqlPack.SelectFields[sqlPack.SelectFields.Count - 1] += " AS " + member.Name;
         }
     }
     return(sqlPack);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Select
        /// </summary>
        /// <param name="expression">表达式树</param>
        /// <returns>SqlBuilderCore</returns>
        public SqlBuilderCore <T> Select(Expression <Func <T, object> > expression = null)
        {
            var sql = SelectParser(typeof(T));

            if (expression == null)
            {
                this._sqlPack.Sql.AppendFormat(sql, "*");
            }
            else
            {
                SqlBuilderProvider.Select(expression.Body, this._sqlPack);
                this._sqlPack.Sql.AppendFormat(sql, this._sqlPack.SelectFieldsStr);
            }
            return(this);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Select
        /// </summary>
        /// <typeparam name="T2">泛型类型2</typeparam>
        /// <typeparam name="T3">泛型类型3</typeparam>
        /// <param name="expression">表达式树</param>
        /// <returns>SqlBuilderCore</returns>
        public SqlBuilderCore <T> Select <T2, T3>(Expression <Func <T, T2, T3, object> > expression = null)
            where T2 : class
            where T3 : class
        {
            var sql = SelectParser(typeof(T), typeof(T2), typeof(T3));

            if (expression == null)
            {
                this._sqlPack.Sql.AppendFormat(sql, "*");
            }
            else
            {
                SqlBuilderProvider.Select(expression.Body, this._sqlPack);
                this._sqlPack.Sql.AppendFormat(sql, this._sqlPack.SelectFieldsStr);
            }
            return(this);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Select
        /// </summary>
        /// <typeparam name="T2">泛型类型2</typeparam>
        /// <typeparam name="T3">泛型类型3</typeparam>
        /// <typeparam name="T4">泛型类型4</typeparam>
        /// <typeparam name="T5">泛型类型5</typeparam>
        /// <typeparam name="T6">泛型类型6</typeparam>
        /// <typeparam name="T7">泛型类型7</typeparam>
        /// <typeparam name="T8">泛型类型8</typeparam>
        /// <typeparam name="T9">泛型类型9</typeparam>
        /// <param name="expression">表达式树</param>
        /// <returns>SqlBuilderCore</returns>
        public SqlBuilderCore <T> Select <T2, T3, T4, T5, T6, T7, T8, T9>(Expression <Func <T, T2, T3, T4, T5, T6, T7, T8, T9, object> > expression = null)
            where T2 : class
            where T3 : class
            where T4 : class
            where T5 : class
            where T6 : class
            where T7 : class
            where T8 : class
            where T9 : class
        {
            var sql = SelectParser(typeof(T), typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9));

            if (expression == null)
            {
                this._sqlPack.Sql.AppendFormat(sql, "*");
            }
            else
            {
                SqlBuilderProvider.Select(expression.Body, this._sqlPack);
                this._sqlPack.Sql.AppendFormat(sql, this._sqlPack.SelectFieldsStr);
            }
            return(this);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Select
 /// </summary>
 /// <param name="expression">表达式树</param>
 /// <param name="sqlPack">sql打包对象</param>
 /// <returns>SqlPack</returns>
 public override SqlPack Select(UnaryExpression expression, SqlPack sqlPack)
 {
     SqlBuilderProvider.Select(expression.Operand, sqlPack);
     return(sqlPack);
 }