Beispiel #1
0
        private SqlQueryable <T> SelectParser(Expression expression, Expression expressionBody, params Type[] ary)
        {
            this.ClearSelect();
            this._sqlBuilder.SetSqlCommandType(SqlCommandType.Select);
            this._sqlBuilder.IsAddSelect   = true;
            this._sqlBuilder.IsSingleTable = false;

            foreach (var item in ary)
            {
                string tableName = item.GetTableName(_sqlBuilder._dbSqlParser);
                this._sqlBuilder.SetTableAlias(tableName);
            }

            this._sqlBuilder.SqlSelectStr = "select {0} from " + this._mainTableName + " " + this._sqlBuilder.GetTableAlias(this._mainTableName);

            if (expression != null)
            {
                SqlProvider.Select(expressionBody, this._sqlBuilder);
            }

            return(this);
        }
Beispiel #2
0
        protected override SqlBuilder Select(MemberInitExpression expression, SqlBuilder sqlBuilder)
        {
            var bindings = expression.Bindings;

            var names = expression.Bindings.Select(m => m.Member.Name).ToArray();

            foreach (MemberAssignment memberAss in expression.Bindings)
            {
                var property = memberAss.Member as PropertyInfo;

                //排序非数据项
                if (property.IsNotColumn(expression.Type))
                {
                    continue;
                }

                SqlProvider.Select(memberAss.Expression, sqlBuilder);
                //添加字段别名
                sqlBuilder.SelectFieldsAlias.Add($"{sqlBuilder._dbSqlParser.ElementLeftPrefix}{memberAss.Member.Name}{sqlBuilder._dbSqlParser.ElementRightPrefix}");
            }

            return(sqlBuilder);
        }
        protected override SqlBuilder Select(NewExpression expression, SqlBuilder sqlBuilder)
        {
            for (int i = 0; i < expression.Arguments.Count; i++)
            {
                var argument = expression.Arguments[i];

                var          mermberExpression = ((MemberExpression)argument);
                PropertyInfo property          = mermberExpression.Member as PropertyInfo;

                //排除非数据列
                if (property.IsNotColumn(mermberExpression.Expression.Type))
                {
                    continue;
                }

                SqlProvider.Select(argument, sqlBuilder);

                var fieldName = expression.Members[i].Name;

                sqlBuilder.SelectFieldsAlias.Add($"[{fieldName}]");
            }

            return(sqlBuilder);
        }
 protected override SqlBuilder Select(ParameterExpression expression, SqlBuilder sqlBuilder)
 {
     SqlProvider.Select(expression, sqlBuilder);
     return(sqlBuilder);
 }
Beispiel #5
0
 protected override SqlBuilder Select(UnaryExpression expression, SqlBuilder sqlBuilder)
 {
     SqlProvider.Select(expression.Operand, sqlBuilder);
     return(sqlBuilder);
 }