The following is the code I am using to query the database. The variable "filter" is a linq expression. It seems that I can use this code to get data using ObjectId or any other value that may be in the document. But when I store a Guid and try to retrieve it, there is no return. Is there something I am doing wrong here, or is there a limitation on MongoDB itself when it comes to Guids?
_dbSet = mongoDatabase.GetCollection(collectionName);
var query = _dbSet.AsQueryable<TEntity>();
if (filter != null)
{
query = query.Where(filter);
}
return query.ToList();
EDIT:
Just to clarify a bit more. I have tried the solution shown here in the last comment: MongoDB and Guid in Linq Where clause. That does not give me a result either. The data I am trying to retrieve contains just the _id field.
{
"_id" : LUUID("e5bdda3b-ae6a-d942-bd43-c8c7a6803096")
}
The entity being used to retrieve this object has only a property called Id which, from what I understand, translates to the _id field in the Mongo document. So I tried retrieving on the Id property as well. Still no result.
Extending @jjkim's answer as I could not post image in comment:
You need to change the preference which comes under "Edit > Preferences" in Studio 3T for MongoDB.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With