当前位置: 首页>>代码示例>>C#>>正文


C# CommandDocument.AddRange方法代码示例

本文整理汇总了C#中MongoDB.Driver.CommandDocument.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# CommandDocument.AddRange方法的具体用法?C# CommandDocument.AddRange怎么用?C# CommandDocument.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MongoDB.Driver.CommandDocument的用法示例。


在下文中一共展示了CommandDocument.AddRange方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExecuteJsShell

 /// 注意:有些命令可能只能用在mongos上面,例如addshard
 /// <summary>
 ///     使用Shell Helper命令
 /// </summary>
 /// <param name="JsShell"></param>
 /// <param name="mongoSvr"></param>
 /// <returns></returns>
 public static CommandResult ExecuteJsShell(String JsShell, MongoServer mongoSvr)
 {
     var ShellCmd = new BsonDocument {{"$eval", new BsonJavaScript(JsShell)}, {"nolock", true}};
     //必须nolock
     var mongoCmd = new CommandDocument();
     mongoCmd.AddRange(ShellCmd);
     return ExecuteMongoSvrCommand(mongoCmd, mongoSvr);
 }
开发者ID:EricBlack,项目名称:MagicMongoDBTool,代码行数:15,代码来源:MongoDBHelper_Command_Run.cs

示例2: ExecuteJsShell

 /// <summary>
 /// 使用Shell Helper命令
 /// </summary>
 /// <param name="JsShell"></param>
 /// <param name="mongoSvr"></param>
 /// <returns></returns>
 public static CommandResult ExecuteJsShell(String JsShell, MongoServer mongoSvr)
 {
     BsonDocument ShellCmd = new BsonDocument();
     ShellCmd.Add("$eval", new BsonJavaScript(JsShell));
     //必须nolock
     ShellCmd.Add("nolock", true);
     CommandDocument mongoCmd = new CommandDocument();
     mongoCmd.AddRange(ShellCmd);
     return ExecuteMongoSvrCommand(mongoCmd, mongoSvr);
 }
开发者ID:huchao007,项目名称:MagicMongoDBTool,代码行数:16,代码来源:MongoDBHelper_Command_Run.cs

示例3: ExecuteMongoColCommand

 /// <summary>
 /// 执行数据集命令
 /// </summary>
 /// <param name="CommandString"></param>
 /// <param name="mongoCol"></param>
 /// <returns></returns>
 public static CommandResult ExecuteMongoColCommand(String CommandString, MongoCollection mongoCol)
 {
     CommandResult mCommandResult;
     BsonDocument BaseCommand = new BsonDocument();
     BaseCommand.Add(CommandString, mongoCol.Name);
     CommandDocument mongoCmd = new CommandDocument();
     mongoCmd.AddRange(BaseCommand);
     try
     {
         mCommandResult = mongoCol.Database.RunCommand(mongoCmd);
     }
     catch (MongoCommandException ex)
     {
         mCommandResult = ex.CommandResult;
     }
     RunCommandEventArgs e = new RunCommandEventArgs();
     e.CommandString = CommandString;
     e.RunLevel = PathLv.CollectionLV;
     e.Result = mCommandResult;
     OnCommandRunComplete(e);
     return mCommandResult;
 }
开发者ID:huchao007,项目名称:MagicMongoDBTool,代码行数:28,代码来源:MongoDBHelper_Command_Run.cs

示例4: ExecuteMongoColCommand

 /// <summary>
 ///     执行数据集命令
 /// </summary>
 /// <param name="commandString"></param>
 /// <param name="mongoCol"></param>
 /// <returns></returns>
 public static CommandResult ExecuteMongoColCommand(string commandString, MongoCollection mongoCol)
 {
     CommandResult mCommandResult;
     var baseCommand = new BsonDocument { { commandString, mongoCol.Name } };
     var mongoCmd = new CommandDocument();
     mongoCmd.AddRange(baseCommand);
     try
     {
         mCommandResult = mongoCol.Database.RunCommand(mongoCmd);
     }
     catch (MongoCommandException ex)
     {
         mCommandResult = new CommandResult(ex.Result);
     }
     var e = new RunCommandEventArgs
     {
         CommandString = commandString,
         RunLevel = EnumMgr.PathLevel.CollectionAndView,
         Result = mCommandResult
     };
     OnCommandRunComplete(e);
     return mCommandResult;
 }
开发者ID:magicdict,项目名称:MongoCola,代码行数:29,代码来源:CommandExecute.cs

示例5: InitReplicaSet

        /// <summary>
        ///     初始化副本(数据库版本 - 废止)
        /// </summary>
        /// <param name="replicaSetName">副本名称</param>
        /// <param name="hostList">从属服务器列表</param>
        /// <param name="configs"></param>
        public static CommandResult InitReplicaSet(string replicaSetName, string hostList,
            Dictionary<string, MongoConnectionConfig> configs)
        {
            //第一台服务器作为Primary服务器
            var primarySetting = new MongoClientSettings
            {
                Server = new MongoServerAddress(configs[hostList].Host,
                    configs[hostList].Port),
                ReadPreference = ReadPreference.PrimaryPreferred
            };
            //如果不设置的话,会有错误:不是Primary服务器,SlaveOK 是 False

            var primarySvr = new MongoClient(primarySetting).GetServer();
            var config = new BsonDocument();
            var hosts = new BsonArray();
            var replSetInitiateCmd = new BsonDocument();
            var host = new BsonDocument();
            //生成命令
            host = new BsonDocument
            {
                {ConstMgr.KeyId, 1},
                {
                    "host", configs[hostList].Host + ":" + configs[hostList].Port
                }
            };
            hosts.Add(host);
            config.Add(ConstMgr.KeyId, replicaSetName);
            config.Add("members", hosts);
            replSetInitiateCmd.Add("replSetInitiate", config);

            var mongoCmd = new CommandDocument();
            mongoCmd.AddRange(replSetInitiateCmd);
            return ExecuteMongoSvrCommand(mongoCmd, primarySvr);
        }
开发者ID:magicdict,项目名称:MongoCola,代码行数:40,代码来源:DataBaseCommand.cs

示例6: ExecuteMongoColCommand

 /// <summary>
 ///     执行数据集命令
 /// </summary>
 /// <param name="CommandString"></param>
 /// <param name="mongoCol"></param>
 /// <returns></returns>
 public static CommandResult ExecuteMongoColCommand(String CommandString, MongoCollection mongoCol)
 {
     CommandResult mCommandResult;
     var BaseCommand = new BsonDocument {{CommandString, mongoCol.Name}};
     var mongoCmd = new CommandDocument();
     mongoCmd.AddRange(BaseCommand);
     try
     {
         mCommandResult = mongoCol.Database.RunCommand(mongoCmd);
     }
     catch (MongoCommandException ex)
     {
         mCommandResult = ex.CommandResult;
     }
     var e = new RunCommandEventArgs
     {
         CommandString = CommandString,
         RunLevel = MongoDbHelper.PathLv.CollectionLv,
         Result = mCommandResult
     };
     OnCommandRunComplete(e);
     return mCommandResult;
 }
开发者ID:EricBlack,项目名称:MagicMongoDBTool,代码行数:29,代码来源:MongoDBHelper_Command_Run.cs

示例7: InitReplicaSet

        /// <summary>
        ///     初始化副本
        /// </summary>
        /// <param name="replicaSetName">副本名称</param>
        /// <param name="hostList">从属服务器列表</param>
        public static CommandResult InitReplicaSet(String replicaSetName, String hostList)
        {
            //第一台服务器作为Primary服务器
            var PrimarySetting = new MongoClientSettings
            {
                Server = new MongoServerAddress(SystemManager.ConfigHelperInstance.ConnectionList[hostList].Host,
                    SystemManager.ConfigHelperInstance.ConnectionList[hostList].Port),
                ReadPreference = ReadPreference.PrimaryPreferred
            };
            //如果不设置的话,会有错误:不是Primary服务器,SlaveOK 是 False

            MongoServer PrimarySvr = new MongoClient(PrimarySetting).GetServer();
            var config = new BsonDocument();
            var hosts = new BsonArray();
            var replSetInitiateCmd = new BsonDocument();
            var host = new BsonDocument();
            //生成命令
            host = new BsonDocument
            {
                {MongoDbHelper.KEY_ID, 1},
                {
                    "host", SystemManager.ConfigHelperInstance.ConnectionList[hostList].Host + ":" +
                            SystemManager.ConfigHelperInstance.ConnectionList[hostList].Port
                }
            };
            hosts.Add(host);
            config.Add(MongoDbHelper.KEY_ID, replicaSetName);
            config.Add("members", hosts);
            replSetInitiateCmd.Add("replSetInitiate", config);

            var mongoCmd = new CommandDocument();
            mongoCmd.AddRange(replSetInitiateCmd);
            return ExecuteMongoSvrCommand(mongoCmd, PrimarySvr);
        }
开发者ID:EricBlack,项目名称:MagicMongoDBTool,代码行数:39,代码来源:MongoDBHelper_Command_Define.cs

示例8: InitReplicaSet

        /// <summary>
        /// 初始化副本
        /// </summary>
        /// <param name="mongoSvr">副本组主服务器</param>
        /// <param name="replicaSetName">副本名称</param>
        /// <param name="HostList">从属服务器列表</param>
        public static CommandResult InitReplicaSet(String replicaSetName, String HostList)
        {
            //第一台服务器作为Primary服务器
            MongoClientSettings PrimarySetting = new MongoClientSettings();
            PrimarySetting.Server = new MongoServerAddress(SystemManager.ConfigHelperInstance.ConnectionList[HostList].Host,
                                                           SystemManager.ConfigHelperInstance.ConnectionList[HostList].Port);
            //如果不设置的话,会有错误:不是Primary服务器,SlaveOK 是 False
            PrimarySetting.ReadPreference = ReadPreference.PrimaryPreferred;

            MongoServer PrimarySvr = new MongoClient(PrimarySetting).GetServer();
            BsonDocument config = new BsonDocument();
            BsonArray hosts = new BsonArray();
            BsonDocument replSetInitiateCmd = new BsonDocument();
            BsonDocument host = new BsonDocument();
            //生成命令
            host = new BsonDocument();
            host.Add(KEY_ID, 1);
            host.Add("host", SystemManager.ConfigHelperInstance.ConnectionList[HostList].Host + ":" + SystemManager.ConfigHelperInstance.ConnectionList[HostList].Port.ToString());
            hosts.Add(host);
            config.Add(KEY_ID, replicaSetName);
            config.Add("members", hosts);
            replSetInitiateCmd.Add("replSetInitiate", config);

            CommandDocument mongoCmd = new CommandDocument();
            mongoCmd.AddRange(replSetInitiateCmd);
            return ExecuteMongoSvrCommand(mongoCmd, PrimarySvr);
        }
开发者ID:qq33357486,项目名称:MagicMongoDBTool,代码行数:33,代码来源:MongoDBHelper_Command.cs


注:本文中的MongoDB.Driver.CommandDocument.AddRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。