I am trying to loop through id's in a collection for a MongoDb database. The goal is to loop trough these id's and use the id's to create a json files with the different id's. I believe the query that I wrote is returning all the id's, but then i get the below error.
Inner Exception 1:
FormatException: '9a1c458c-82Dd-43b4-a963-76a96d374580' is not a valid 24 digit hex string.
Below is my query to get all the id's
var thingsDoc = demoThings.AsQueryable().Where(a => a._id != null).ToList();
Below is my class of properties for Things
public class Things
{
[BsonRepresentation(BsonType.ObjectId)]
public ObjectId _id { get; set; }
}
I believe the issue is with how the properties are defined. Or maybe it is a problem with my query? From research I know the reason it is complaining is because of the dashes in the format. But not finding any work arounds to resolve this. Help is much appreciated.