1

I'm trying to insert into a mongodb database without having to specify a class to save it to, I just want to insert it, I don't want to save any of it to a class. Is there a way to just simply insert it?

Code:

var collection = _database<Entity>(table);
await collection.InsertOneAsync(new Entity { Name = "Jack" });

Im trying to do it in a method like this:

public void InsertRecord(string table, List<string> columns, Dictionary<string, string> parameters)
{
    var collection = _database<Entity>(table);
    await collection.InsertOneAsync(new Entity { Name = "Jack" });
}

1 Answers1

0

If you don't specify class, you need BSON documents. Here is example how to work with them:

mongodb c# how to work with BSON document

BOR4
  • 610
  • 4
  • 9