本文整理汇总了C#中MongoServer.RequestStart方法的典型用法代码示例。如果您正苦于以下问题:C# MongoServer.RequestStart方法的具体用法?C# MongoServer.RequestStart怎么用?C# MongoServer.RequestStart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoServer
的用法示例。
在下文中一共展示了MongoServer.RequestStart方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertGroupPost
private static void InsertGroupPost(MongoServer mongo, MongoDatabase db, SqlCommand cmd)
{
cmd.CommandText = "delete from DoubanPost";
cmd.ExecuteNonQuery();
using (mongo.RequestStart(db))
{
var collection = db.GetCollection<BsonDocument>("postinfo_collection");
foreach (var item in collection.FindAll())
{
var list = item.RawValues.ToList();
cmd.CommandText = "insert into DoubanPost values (@v1,@v2,@v3)";
int v3;
if (!int.TryParse(list[3].ToString(), out v3))
{
v3 = -1;
}
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@v1", list[1].ToString());
cmd.Parameters.AddWithValue("@v2", list[2].ToString());
cmd.Parameters.AddWithValue("@v3", v3);
cmd.ExecuteNonQuery();
}
}
}
示例2: FailPoint
// constructors
public FailPoint(string name, MongoServer server, MongoServerInstance serverInstance)
{
if (name == null) { throw new ArgumentNullException("name"); }
if (server == null) { throw new ArgumentNullException("server"); }
if (serverInstance == null) { throw new ArgumentNullException("serverInstance"); }
if (server.RequestConnection != null)
{
throw new InvalidOperationException("FailPoint cannot be used when you are already in a RequestStart.");
}
_name = name;
_server = server;
_serverInstance = serverInstance;
_adminDatabase = server.GetDatabase("admin");
_request = server.RequestStart(_adminDatabase, serverInstance);
}