-
Type: Bug
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Affects Version/s: 3.0.0
-
Component/s: GridFS
-
None
-
Dotnet Drivers
Summary
If we query a gridfs collection and just want to retrieve the Id we had this code prior to upgrading to V3 driver:
var id = await db .GetCollection<GridFSFileInfo>() .Find(Builders<GridFSFileInfo>.Filter.Empty) // For simplicity .Project(x => x.Id) .SingleOrDefaultAsync();
After upgrading to V3 driver you get this exception:
System.InvalidOperationException: Serializer for MongoDB.Driver.GridFS.GridFSFileInfo does not have a member named Id.
As a workaround i have this code now but IdAsBsonValue is obsolete.
var id = (await db.GetCollection<GridFSFileInfo>() .Find(Builders<GridFSFileInfo>.Filter.Empty) // For simplicity .Project(x => x.IdAsBsonValue) .SingleOrDefaultAsync()) ?.AsObjectId;
Now I'm unsure if it is an intended change within V3 driver or should we create own POCO classes if we want to load minimal data from GridFS?