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));
        }
Ejemplo n.º 2
0
        /// <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"]);
        }
Ejemplo n.º 3
0
 public EvalSettings(EvalFlags flags)
 {
     this.Flags = flags;
 }
Ejemplo n.º 4
0
 public EvalSettings(EvalFlags flags, params object [] varValues) : this( varValues ) {
     this.Flags = flags;
 }
Ejemplo n.º 5
0
 public BsonValue Eval(EvalFlags flags, BsonJavaScript code, object[] args)
 {
     return(_mongoDatabase.Eval(flags, code, args));
 }