示例#1
0
        internal override string CreateSqlString(CommandFactory factory, bool isFullName, CreateSqlState state)
        {
            string sql = state.GetDataSql(this, isFullName);

            if (sql != null)
            {
                return(sql);
            }

            object        left;
            object        right;
            DataFieldInfo leftInfo  = _left as DataFieldInfo;
            DataFieldInfo rightInfo = _right as DataFieldInfo;

            if (!Object.Equals(leftInfo, null) && !Object.Equals(rightInfo, null))
            {
                left  = leftInfo.CreateSqlString(factory, isFullName, state);
                right = rightInfo.CreateSqlString(factory, isFullName, state);
            }
            else if (!Object.Equals(leftInfo, null))
            {
                left = leftInfo.CreateSqlString(factory, isFullName, state);
                object rightObject = LambdaExpressionExtend.ConvertLambdaObject(_right);
                right = state.AddDataParameter(factory, rightObject);
            }
            else if (!Object.Equals(rightInfo, null))
            {
                right = rightInfo.CreateSqlString(factory, isFullName, state);
                object leftObject = LambdaExpressionExtend.ConvertLambdaObject(_left);
                left = state.AddDataParameter(factory, leftObject);
            }
            else
            {
                throw new LightDataException(SR.DataFieldContentError);
            }
            sql = factory.CreateLikeMatchQuerySql(left, right, _starts, _ends, _isNot);
            state.SetDataSql(this, isFullName, sql);
            return(sql);
        }