MongoClient client;
MongoServer server;
MongoDatabase database;
client = new MongoClient("mongodb://192.168.0.4");
server = client.GetServer();
database = server.GetDatabase("数据库名");
var connected = database.GetCollection("集合名");
var connected_all = connected.FindAll();
List<string> source_id_list = new List<string>();
foreach (var ttdoc2 in connected_all)
{
source_id_list.Add(ttdoc2.AsBsonDocument["source_id"].ToString());
}
if (!source_id_list.Contains(要插入数据的id))
{
//当已有的数据id中没有该数据id时进行插入数据