I'm working with MongoDB and c #, this is the way I insert Data.
My Class Employees
public class Empleados
{
public string Nombre{ get; set; }
public string Direccion { get; set; }
}
Button Method
Empleados empleado= new Empleados ();
empleado.Nombre= "Rastalovely";
empleado.Direccion= "Mexico";
Insert_Empleados(empleado);
Private Method
private void Insert_Empleados(Empleados empleado)
{
var coleccion = data.GetCollection<BsonDocument>("empleados");
BsonDocument documento = empleado.ToBsonDocument();
coleccion.InsertOne(documento);
}
What I need is to get the ID of the last employee added.