本文整理汇总了C#中MongoDB.Driver.Document.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# Document.Contains方法的具体用法?C# Document.Contains怎么用?C# Document.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoDB.Driver.Document
的用法示例。
在下文中一共展示了Document.Contains方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestRemove
public void TestRemove()
{
Document d = new Document();
d["one"] = 1;
d.Remove("one");
Assert.IsFalse(d.Contains("one"));
}
示例2: DBRef
/// <summary>
/// Constructs a DBRef from a document that matches the DBref specification.
/// </summary>
public DBRef(Document document)
{
if(IsDocumentDBRef(document) == false) throw new ArgumentException("Document is not a valid DBRef");
collectionName = (String)document[RefName];
id = document[IdName];
this.document = document;
if(document.Contains("metadata")) this.MetaData = (Document)document["metadata"];
}
示例3: CopyTo
/// <summary>
/// TODO Fix any accidental reordering issues.
/// </summary>
/// <param name="dest"></param>
public void CopyTo(Document dest)
{
foreach (String key in orderedKeys) {
if (dest.Contains (key))
dest.Remove (key);
dest[key] = this[key];
}
}
示例4: TestClearRemovesAll
public void TestClearRemovesAll()
{
Document d = new Document();
d["one"] = 1;
d.Add("two", 2);
d["three"] = 3;
Assert.AreEqual(3,d.Count);
d.Clear();
Assert.AreEqual(0, d.Count);
Assert.IsNull(d["one"]);
Assert.IsFalse(d.Contains("one"));
}
示例5: Update
public void Update(Document doc)
{
//Try to generate a selector using _id for an existing document.
//otherwise just set the upsert flag to 1 to insert and send onward.
Document selector = new Document();
int upsert = 0;
if(doc.Contains("_id") & doc["_id"] != null){
selector["_id"] = doc["_id"];
}else{
//Likely a new document
doc["_id"] = oidGenerator.Generate();
upsert = 1;
}
this.Update(doc, selector, upsert);
}
示例6: UpdateObjectAlwaysUpsert
//If _id exists but has changed save new object
private void UpdateObjectAlwaysUpsert(string collectionName, Document doc, Mong db)
{
if(doc.Contains("_id") && doc["_id"] != null)
{
var selector = new Document();
selector["_id"] = doc["_id"];
db[DataBaseName][collectionName].Update(doc,selector,1);
}
else
db[DataBaseName][collectionName].Update(doc);
}
示例7: IsError
/// <summary>
/// Determines whether the specified document is error.
/// </summary>
/// <param name="document">The document.</param>
/// <returns>
/// <c>true</c> if the specified document is error; otherwise, <c>false</c>.
/// </returns>
public static bool IsError(Document document)
{
if(document.Contains("err") && document["err"] != DBNull.Value)
return true;
return false;
}
示例8: IsDocumentDBRef
public static bool IsDocumentDBRef(Document doc)
{
return doc != null && doc.Contains(RefName) && doc.Contains(IdName);
}
示例9: IsDocumentDBRef
public static bool IsDocumentDBRef(Document doc)
{
return doc.Contains("$ref") && doc.Contains("$id");
}