本文整理汇总了C#中BsonDocument.Where方法的典型用法代码示例。如果您正苦于以下问题:C# BsonDocument.Where方法的具体用法?C# BsonDocument.Where怎么用?C# BsonDocument.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BsonDocument
的用法示例。
在下文中一共展示了BsonDocument.Where方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessDifferencesInDocument
private static BsonDocument ProcessDifferencesInDocument(this BsonDocument a, BsonDocument b)
{
var bson = new BsonDocument();
foreach (var e in a.Where(e => !b.Contains(e.Name)))
{
bson.SetElement(new BsonElement("+a:" + e.Name, e.Value));
}
foreach (var e in b.Where(e => !a.Contains(e.Name)))
{
bson.SetElement(new BsonElement("+b:" + e.Name, e.Value));
}
return bson;
}
示例2: CreateWriteConcernErrorFromGetLastErrorResponse
private static BulkWriteConcernError CreateWriteConcernErrorFromGetLastErrorResponse(BsonDocument getLastErrorResponse)
{
var code = getLastErrorResponse.GetValue("code", 64).ToInt32(); // default = WriteConcernFailed
string message = null;
BsonValue value;
if (getLastErrorResponse.TryGetValue("err", out value) && value.BsonType == BsonType.String)
{
message = value.AsString;
}
else if (getLastErrorResponse.TryGetValue("jnote", out value) && value.BsonType == BsonType.String)
{
message = value.AsString;
}
else if (getLastErrorResponse.TryGetValue("wnote", out value) && value.BsonType == BsonType.String)
{
message = value.AsString;
}
var details = new BsonDocument(getLastErrorResponse.Where(e => !new[] { "ok", "code", "err" }.Contains(e.Name)));
return new BulkWriteConcernError(code, message, details);
}
示例3: Diff
public static BsonDocument Diff(this BsonDocument a, BsonDocument b)
{
if (!a.HasSameElementNamesAs(b))
{
var bson = new BsonDocument();
foreach (var e in a.Where(e => !b.Contains(e.Name)))
{
bson.SetElement(new BsonElement("+a:" + e.Name, e.Value));
}
foreach (var e in b.Where(e => !a.Contains(e.Name)))
{
bson.SetElement(new BsonElement("+b:" + e.Name, e.Value));
}
return bson;
}
else
{
var bson = new BsonDocument();
foreach (var e in a)
{
var d = Diff(e.Value, b[e.Name]);
if (d.ElementCount > 0)
bson.Add(e.Name, d);
}
return bson;
}
}