/// <summary> /// Creates a <see cref="ModifyStatement"/> with the given condition that can be used to modify one or more /// documents from a collection. /// </summary> /// <param name="condition">The condition to match documents.</param> /// <returns>A <see cref="ModifyStatement"/> object set with the given condition.</returns> /// <exception cref="ArgumentNullException"><paramref name="condition"/> is <c>null</c> or white space.</exception> /// <remarks>The statement can then be further modified before execution.</remarks> public ModifyStatement Modify(string condition) { if (string.IsNullOrWhiteSpace(condition)) { throw new ArgumentNullException(nameof(condition), Resources.ParameterNullOrEmpty); } ModifyStatement stmt = new ModifyStatement(this, condition); return(stmt); }
protected Result ExecuteModifyStatement(ModifyStatement stmt) { return(stmt.Execute()); }
public int PrepareStatement <TResult>(BaseStatement <TResult> statement) where TResult : BaseResult { int stmtId = Interlocked.Increment(ref _stmtId); switch (statement.GetType().Name) { case nameof(FindStatement): FindStatement fs = statement as FindStatement; Debug.Assert(fs != null); protocol.SendPrepareStatement( (uint)stmtId, DataAccess.PreparedStatementType.Find, fs.Target.Schema.Name, fs.Target.Name, false, fs.FilterData, fs.findParams); break; case nameof(TableSelectStatement): TableSelectStatement ss = statement as TableSelectStatement; Debug.Assert(ss != null); protocol.SendPrepareStatement( (uint)stmtId, DataAccess.PreparedStatementType.Find, ss.Target.Schema.Name, ss.Target.Name, true, ss.FilterData, ss.findParams); break; case nameof(ModifyStatement): ModifyStatement ms = statement as ModifyStatement; Debug.Assert(ms != null); protocol.SendPrepareStatement( (uint)stmtId, DataAccess.PreparedStatementType.Update, ms.Target.Schema.Name, ms.Target.Name, false, ms.FilterData, null, ms.Updates); break; case nameof(TableUpdateStatement): TableUpdateStatement us = statement as TableUpdateStatement; Debug.Assert(us != null); protocol.SendPrepareStatement( (uint)stmtId, DataAccess.PreparedStatementType.Update, us.Target.Schema.Name, us.Target.Name, true, us.FilterData, null, us.updates); break; case nameof(RemoveStatement): RemoveStatement rs = statement as RemoveStatement; Debug.Assert(rs != null); protocol.SendPrepareStatement( (uint)stmtId, DataAccess.PreparedStatementType.Delete, rs.Target.Schema.Name, rs.Target.Name, false, rs.FilterData, null); break; case nameof(TableDeleteStatement): TableDeleteStatement ds = statement as TableDeleteStatement; Debug.Assert(ds != null); protocol.SendPrepareStatement( (uint)stmtId, DataAccess.PreparedStatementType.Delete, ds.Target.Schema.Name, ds.Target.Name, true, ds.FilterData, null); break; case nameof(TableInsertStatement): TableInsertStatement insert = statement as TableInsertStatement; Debug.Assert(insert != null); protocol.SendPrepareStatement( (uint)stmtId, DataAccess.PreparedStatementType.Insert, insert.Target.Schema.Name, insert.Target.Name, true, null, null, null, insert.values.ToArray(), insert.fields, false); break; case nameof(SqlStatement): SqlStatement sqlStatement = statement as SqlStatement; Debug.Assert(sqlStatement != null); protocol.SendPrepareStatement( (uint)stmtId, DataAccess.PreparedStatementType.SqlStatement, null, null, true, null, null, null, sqlStatement.parameters.ToArray(), null, false, sqlStatement.SQL); break; default: throw new NotSupportedException(statement.GetType().Name); } _preparedStatements.Add(stmtId); return(stmtId); }
public Result ModifyDocs(ModifyStatement ms) { protocol.SendUpdate(ms.Target.Schema.Name, ms.Target.Name, false, ms.FilterData, ms.Updates); return(new Result(this)); }