public virtual BsonValue Eval(EvalFlags flags, BsonJavaScript code, params object[] args) { var mappedArgs = args.Select(a => BsonTypeMapper.MapToBsonValue(a)); var @lock = ((flags & EvalFlags.NoLock) != 0) ? (bool?)false : null; var evalArgs = new EvalArgs { Code = code, Args = mappedArgs, Lock = @lock }; return(Eval(evalArgs)); }
/// <summary> /// Evaluates JavaScript code at the server. /// </summary> /// <param name="flags">Flags that control Eval options.</param> /// <param name="code">The code to evaluate.</param> /// <param name="args">Optional arguments (only used when the code is a function with parameters).</param> /// <returns>The result of evaluating the code.</returns> public virtual BsonValue Eval(EvalFlags flags, BsonJavaScript code, params object[] args) { var command = new CommandDocument { { "$eval", code }, { "args", BsonArray.Create(args), args != null && args.Length > 0 }, { "nolock", true, (flags & EvalFlags.NoLock) != 0 } }; var result = RunCommand(command); return(result.Response["retval"]); }
public EvalSettings(EvalFlags flags) { this.Flags = flags; }
public EvalSettings(EvalFlags flags, params object [] varValues) : this( varValues ) { this.Flags = flags; }
public BsonValue Eval(EvalFlags flags, BsonJavaScript code, object[] args) { return(_mongoDatabase.Eval(flags, code, args)); }