I have a very simple LinqToSql list.
var list = DB.Where(c => c.Status.Equals("active")).Select(c => c.Name);
I'm trying to import that list into MongoDB. Here's what I have so far:
const string connectionString = "mongodb://localhost";
var client = new MongoClient(connectionString);
MongoServer server = client.GetServer();
MongoDatabase database = server.GetDatabase("test");
var collection = database.GetCollection("salesppl");
collection.Insert(list);
I have also tried InsertBatch and Save, but with no luck. Here are the error messages I get for each: InsertBatch
BsonSerializationException: Serializer StringSerializer expected serialization options of type RepresentationSerializationOptions, not DocumentSerializationOptions.
Insert
BsonSerializationException: Serializer EnumerableSerializer expected serialization options of type ArraySerializationOptions, not DocumentSerializationOptions.
Save
InvalidOperationException: Save can only be used with documents that have an Id.
Note: I don't think this is of any relevance, but I'm doing this through LinqPad.
So, how can I save this list to MongoDb?