Esempio n. 1
0
        private ExpressionToSql <T> JoinParser2 <T2, T3>(Expression <Func <T2, T3, bool> > expression, bool blnWithNoLock = false, string leftOrRightJoin = "")
        {
            if (expression == null)
            {
                throw new ArgumentNullException("expression", "Value cannot be null");
            }

            string joinTableName = typeof(T3).Name;

            this._sqlBuilder.SetTableAlias(joinTableName);
            string strAlias = this._sqlBuilder.QueueEnglishWords.Dequeue();

            this._sqlBuilder.JoinTables.Add(strAlias, joinTableName);
            if (_sqlBuilder.JoinTables.Count(t => t.Value.Equals(joinTableName)) > 1)
            {
                this._sqlBuilder.AppendFormat("\n{0}join {1} on", leftOrRightJoin, joinTableName + " " + strAlias);
            }
            else
            {
                this._sqlBuilder.AppendFormat("\n{0}join {1} on", leftOrRightJoin,
                                              joinTableName + " " + this._sqlBuilder.GetTableAlias(joinTableName));
            }
            if (blnWithNoLock)
            {
                this._sqlBuilder.AppendFormat(" {0} ", AsNoLock());
            }
            Expression2SqlProvider.Join(expression.Body, this._sqlBuilder);
            return(this);
        }
Esempio n. 2
0
        protected override SqlBuilder Join(BinaryExpression expression, SqlBuilder sqlBuilder)
        {
            Expression2SqlProvider.Join(expression.Left, sqlBuilder);
            int operatorIndex = sqlBuilder.Length;

            Expression2SqlProvider.Join(expression.Right, sqlBuilder);
            int sqlLength = sqlBuilder.Length;

            if (sqlLength - operatorIndex == 5 && sqlBuilder.Sql.EndsWith("null"))
            {
                OperatorParser(expression.NodeType, operatorIndex, sqlBuilder, true);
            }
            else
            {
                OperatorParser(expression.NodeType, operatorIndex, sqlBuilder);
            }

            return(sqlBuilder);
        }