Esempio n. 1
0
        public int Execute(Type elementType, IDictionary <MemberExpression, object> properties, Expression predicate)
        {
            OracleUpdateCommandBuilder updateBuilder = new OracleUpdateCommandBuilder(elementType.Name);

            foreach (var item in properties)
            {
                updateBuilder.AddColumn(item.Key.Member.Name, item.Value);
            }

            if (predicate != null)
            {
                OracleWherePartsCommandBuilder whereBuider = new OracleWherePartsCommandBuilder(updateBuilder.Parameters);

                Expression expression = PartialEvaluatingExpressionTreeVisitor.EvaluateIndependentSubtrees(predicate);

                OracleWhereClauseVisitor visitor = new OracleWhereClauseVisitor();

                visitor.Translate(expression, whereBuider);

                updateBuilder.WhereParts = whereBuider.WherePartsBuilder.ToString();
            }

            this.sessionProvider.ExecutedCommandBuilder = updateBuilder;

            return(this.sessionProvider.ExecuteNonQuery(updateBuilder));
        }
Esempio n. 2
0
        /// <summary>
        /// 解析 Where 语句
        /// </summary>
        /// <param name="whereClause"></param>
        /// <param name="queryModel"></param>
        /// <param name="index"></param>
        public override void VisitWhereClause(WhereClause whereClause, QueryModel queryModel, int index)
        {
            OracleWherePartsCommandBuilder whereBuilder = new OracleWherePartsCommandBuilder(this.commandBuilder.Parameters);

            OracleWhereClauseVisitor visitor = new OracleWhereClauseVisitor();

            visitor.Translate(whereClause.Predicate, whereBuilder);

            commandBuilder.WhereParts.Add(whereBuilder.ToString());

            base.VisitWhereClause(whereClause, queryModel, index);
        }
Esempio n. 3
0
        public int Execute(Type elementType, Expression predicate)
        {
            OracleDeleteCommandBuilder deleteBuilder = new OracleDeleteCommandBuilder(elementType.Name);

            if (predicate != null)
            {
                OracleWherePartsCommandBuilder whereBuilder = new OracleWherePartsCommandBuilder(deleteBuilder.Parameters);

                Expression expression = PartialEvaluatingExpressionTreeVisitor.EvaluateIndependentSubtrees(predicate);

                OracleWhereClauseVisitor visitor = new OracleWhereClauseVisitor();

                visitor.Translate(expression, whereBuilder);

                deleteBuilder.WhereParts = whereBuilder.WherePartsBuilder.ToString();
            }

            this.sessionProvider.ExecutedCommandBuilder = deleteBuilder;

            return(this.sessionProvider.ExecuteNonQuery(deleteBuilder));
        }
Esempio n. 4
0
        /// <summary>
        /// 翻译表达式
        /// </summary>
        /// <returns></returns>
        public void Translate(Expression expression, OracleWherePartsCommandBuilder commandBuilder)
        {
            this.commandBuilder = commandBuilder;

            this.VisitExpression(expression);
        }