MongoDBDriver/Collection.cs
/// <summary>
/// Updates a document with the data in doc as found by the selector.
/// </summary>
/// <remarks>
/// _id will be used in the document to create a selector.  If it isn't in
/// the document then it is assumed that the document is new and an upsert is sent to the database
/// instead.
/// </remarks>
Updates a document with the data in doc as found by the selector.
Updates a document with the data in doc as found by the selector .
public void Update(Document doc){
            Document selector = new Document();
            int upsert = 0;
            if(doc.Contains("_id")  & doc["_id"] != null){
                selector["_id"] = doc["_id"];   
            }else{
                doc.Prepend("_id",oidGenerator.Generate());
                upsert = 1;
            }
            this.Update(doc, selector, upsert);
        }
public void Update ( Document doc ) { Document selector = new Document ( ) ; int upsert = 0 ; if ( doc . Contains ( " " ) & doc [ " " ] != null ) { selector [ " " ] = doc [ " " ] ; } else { doc . Prepend ( " " , oidGenerator . Generate ( ) ) ; upsert = 1 ; } this . Update ( doc , selector , upsert ) ; }
Updates a document with the data in doc as found by the selector.
Updates a document with the data in doc as found by the selector .
//Try to generate a selector using _id for an existing document. //otherwise just set the upsert flag to 1 to insert and send onward. //Likely a new document
doc
Document
remarks
_id will be used in the document to create a selector.  If it isn't in
the document then it is assumed that the document is new and an upsert is sent to the database
instead.
_id will be used in the document to create a selector . If it isn ' t in the document then it is assumed that the document is new and an upsert is sent to the database instead .