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)); }
/// <summary> /// 设置过滤条件 /// </summary> /// <param name="func"></param> /// <returns></returns> public IUpdateable <T> Where(Expression <Func <T, bool> > func) { Expression expression = PartialEvaluatingExpressionTreeVisitor.EvaluateIndependentSubtrees(func); OracleWhereClauseVisitor visitor = new OracleWhereClauseVisitor(this.parameters); string whereSqlParts = visitor.Translate(expression); if (this.updatePartsAggregator.Where.Length == 0) { this.updatePartsAggregator.Where.AppendFormat(" ( {0} )", whereSqlParts); } else { this.updatePartsAggregator.Where.AppendFormat(" AND ( {0} )", whereSqlParts); } return(this); }
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)); }
/// <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 ); }
/// <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 ) { OracleWhereClauseVisitor visitor = new OracleWhereClauseVisitor( this.parameters ); string whereParts = visitor.Translate( whereClause.Predicate ); queryPartsAggregator.WhereParts.Add( whereParts ); base.VisitWhereClause( whereClause, queryModel, index ); }