var max = collection.FindAll().SetSortOrder(SortBy.Descending(“seqno”)).SetLimit(1).SetFields(Fields.Include(“seqno”).Exclude(“_id”));
mongo.seqno = 1;
foreach (BsonDocument item in max)
{
mongo.seqno = item.GetValue(“seqno”).ToInt32() + 1;
}
MongoDB.Driver.WriteConcernResult items = collection.Insert(mongo);