Table of Contents

Class ObjectIdEntity

Namespace
MongoDB.Entities
Assembly
MongoDB.Entities.dll

Inherit this class for all entities you want to store in their own collection.

public abstract class ObjectIdEntity : IEntity
Inheritance
ObjectIdEntity
Implements
Inherited Members
Extension Methods

Properties

Id

This property is auto managed. A new ID will be assigned for new entities upon saving.

[BsonId]
public ObjectId Id { get; set; }

Property Value

ObjectId

Methods

GenerateNewID()

Generate and return a new ID from this method. It will be used when saving new entities that don't have their ID set. I.e. if an entity has a default ID value (determined by calling HasDefaultID() /> method), this method will be called for obtaining a new ID value. If you're not doing custom ID generation, simply do return ObjectId.GenerateNewId().ToString()

public object GenerateNewID()

Returns

object

HasDefaultID()

public bool HasDefaultID()

Returns

bool