Closed Ahmad-Aktaa closed 4 years ago
Not sure if you can add through the driver, I have not used this feature before. However you can try to call a function using the following code:
public class TestRepository : BaseMongoRepository, ITestRepository
{
public void MyCustomFunction()
{
var command = new JsonCommand<BsonDocument>($"{{ eval: \"addNumbers({1},{2})\" }}");
var result = MongoDbContext.Database.RunCommand(command)["retval"].ToInt32();
}
......
}
(untested, just looked at https://stackoverflow.com/questions/23709351/calling-a-stored-procedure-in-mongodb-via-c-sharp)
Basically, you can access all the driver methods in your implementation through MongoDbContext.Database
.
Good luck
Hi Alexandre,
How to create MongoDB stored procedure or calling a Stored Procedure in MongoDB via "mongodb-generic-repository" ?