src/MongoDB.Generators/IntIdGeneratorBase.cs
/// <summary>
/// Generates an Id for a document.
/// </summary>
/// <param name="container">The container of the document (it will be an <see cref="MongoDB.Driver.IMongoCollection{T}"/> when called from the C# driver).</param>
/// <param name="document">The document.</param>
/// <returns>An Id.</returns>
Generates an Id for a document.
Generates an Id for a document .
public object GenerateId(object container, object document)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }
            var collection = (IMongoCollection<T>)container;
            var idSequenceCollection = collection.Database.GetCollection<BsonDocument>(_idCollectionName);
            var filter = Builders<BsonDocument>.Filter.Eq("_id", collection.CollectionNamespace.CollectionName);
            var definition = CreateUpdateDefinition();
            var options = new FindOneAndUpdateOptions<BsonDocument>
            {
                IsUpsert = true,
                ReturnDocument = ReturnDocument.After
            };
            var documentResult = idSequenceCollection.FindOneAndUpdate(filter, definition, options);
            var documentValue = documentResult["seq"];
            var convertedValue = Convert(documentValue);
            return convertedValue;
        }
public object GenerateId ( object container , object document ) { if ( container == null ) { throw new ArgumentNullException ( nameof ( container ) ) ; } var collection = ( IMongoCollection < T > ) container ; var idSequenceCollection = collection . Database . GetCollection < BsonDocument > ( _idCollectionName ) ; var filter = Builders < BsonDocument > . Filter . Eq ( " " , collection . CollectionNamespace . CollectionName ) ; var definition = CreateUpdateDefinition ( ) ; var options = new FindOneAndUpdateOptions < BsonDocument > { IsUpsert = true , ReturnDocument = ReturnDocument . After } ; var documentResult = idSequenceCollection . FindOneAndUpdate ( filter , definition , options ) ; var documentValue = documentResult [ " " ] ; var convertedValue = Convert ( documentValue ) ; return convertedValue ; }
Generates an Id for a document.
Generates an Id for a document .
None
container
object
The container of the document (it will be an  when called from the C# driver).
The container of the document ( it will be an when called from the C# driver ) .
document
object
None